[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SSH URL
From: |
Esben Stien |
Subject: |
SSH URL |
Date: |
Sat, 29 Mar 2014 20:40:18 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
In Emacs, I usually open ssh sessions like this:
cd /ssh:foo@baz:~
Is there any way in Emacs to open up SSH URLs', like this?:
ssh://foo:bar@baz
Here's the password included and this is the way I receive SSH urls.
I understand the security aspects of this but I don't care about that
with this project. I use PKI normally, though.
I use the following python script that accepts SSH urls, but I'd rather
use my beloved emacs.
#!/usr/bin/env python
import pexpect
import struct, fcntl, os, sys, signal
import urlparse
def sigwinch_passthrough (sig, data):
# Check for buggy platforms (see pexpect.setwinsize()).
if 'TIOCGWINSZ' in dir(termios):
TIOCGWINSZ = termios.TIOCGWINSZ
else:
TIOCGWINSZ = 1074295912 # assume
s = struct.pack ("HHHH", 0, 0, 0, 0)
a = struct.unpack ('HHHH', fcntl.ioctl(sys.stdout.fileno(), TIOCGWINSZ , s))
global global_pexpect_instance
global_pexpect_instance.setwinsize(a[0],a[1])
url = urlparse.urlparse(sys.argv[1]);
ssh_newkey = 'Are you sure you want to continue connecting'
p=pexpect.spawn('ssh'+' '+url.username+':'+url.password+'@'+url.hostname)
i=p.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT],1)
if i==0:
print "I say yes"
p.sendline('yes')
i=p.expect([ssh_newkey,'password:',pexpect.EOF])
if i==1:
#print "I give password",
p.sendline(url.password)
elif i==2:
print "I either got key or connection timeout"
pass
elif i==3: #timeout
pass
p.sendline("\r")
global global_pexpect_instance
global_pexpect_instance = p
signal.signal(signal.SIGWINCH, sigwinch_passthrough)
try:
p.interact()
sys.exit(0)
except:
sys.exit(1)
--
Esben Stien is b0ef@e s a
http://www. s t n m
irc://irc. b - i . e/%23contact
sip:b0ef@ e e
jid:b0ef@ n n