all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* SSH URL
@ 2014-03-29 19:40 Esben Stien
  2014-03-30  2:51 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Esben Stien @ 2014-03-29 19:40 UTC (permalink / raw
  To: help-gnu-emacs


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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-04-01 14:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-29 19:40 SSH URL Esben Stien
2014-03-30  2:51 ` Stefan Monnier
2014-03-30 17:48   ` Michael Albinus
2014-03-30 18:41     ` Stefan Monnier
2014-03-30 19:26       ` Michael Albinus
2014-04-01 12:57       ` Michael Albinus
2014-04-01 14:29         ` Stefan Monnier
2014-03-31 18:45     ` Esben Stien
2014-04-01  6:38       ` Michael Albinus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.