SSH mode is a emacs package for ssh connection on emacs buffer. This is similar with running ssh command with shell mode (SSH mode uses shell mode as a base), SSH mode is more useful.
Table of Contents
1 Difference with running ssh command with shell mode
Because shell mode opens only one buffer, running ssh with shell mode cannot connect to multiple remote server at the same time. Because SSH mode opens new buffer for each remote connection, SSH mode can connect to multiple remote server at the same time.
When connecting multiple remote server at the same time, Buffer List is as the following.
* *shell* 2091 Shell:run /home/hiroom2/ * *ssh hostname1... 458 ssh:run /scp:hiroom2@hostname1:/home/hiroom2/ * *ssh hostname2... 898 ssh:run /scp:hiroom2@hostname2:/home/hiroom2/
When opening file with C-x C-f or C-x C-f, SSH mode will refer currentn directory of SSH connected remote server. SSH mode can open file to new buffer without any path modification.
M-x dired Dired (directory): /scp:hiroom2@<hostname>:/home/hiroom2/
shell mode will refer current directory of host machine. shell mode needs path modification (Change to /scp:<user>@<hostname>:/<path>).
M-x dired Dired (directory): ~/
2 Install SSH mode
Clone SSH mode source code and copy ssh.el to load-path directory.
$ git clone https://github.com/ieure/ssh-el $ cp ssh-el/ssh.el ~/.elisp/
Append the following to .emacs.
(require 'ssh) (add-hook 'ssh-mode-hook (lambda () (setq ssh-directory-tracking-mode t) (shell-dirtrack-mode t) (setq dirtrackp nil)))
3 Connect to remote server
Type M-x ssh, and input hostname or IP address.
M-x ssh ssh arguments (hostname first): <hostname> or <ipaddr>
Type M-x ssh.
Connected to remote server.
Key binding is same with shell mode. For example, command history can be referred with M-p and M-n.