Support for `user@host’ in ssh-mode

One of my long-time pet peeves with ssh-mode is that it doesn’t understand user@host syntax. If you want to log in to a remote host as a different user, you must use the more verbose host -l user syntax. If you don’t, and you use the `ftp’ ssh-directory-tracking-mode, tramp gets confused and tries to connect to local-user@remote-user@host, which doesn’t work.

The problem is that ssh-mode treats user@host as the host name, rather than the user+host. This patch addresses that flaw, by detecting and handling user@host syntax.

--- ssh.el.orig	2008-08-13 12:55:21.000000000 -0700
+++ ssh.el	2008-08-13 13:19:17.000000000 -0700
@@ -184,13 +184,15 @@

   (let* ((process-connection-type ssh-process-connection-type)
          (args (ssh-parse-words input-args))
-	 (host (car args))
-	 (user (or (car (cdr (member "-l" args)))
+         (host-parts (split-string (car args) "@"))
+         (host (car (last host-parts)))
+         (user (or (cadr (member "-l" args))
+                   (if (= 2 (length host-parts)) (car host-parts))
                    (user-login-name)))
          (buffer-name (if (string= user (user-login-name))
                           (format "*ssh-%s*" host)
                         (format "*ssh-%s@%s*" user host)))
-	 proc)
+         proc)

     (and ssh-explicit-args
          (setq args (append ssh-explicit-args args)))
2008/08/13
Previously On Atomized:

Participate