Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a need to do a lot in vim on a remote server which I need to SSH into. I find that it is best if I can look at multiple documents in multiple windows on my desktop, so to do this I open two or three SSH sessions to the remote server. This is getting a bit tedious though, as I have to re-enter the un/pw several times, and I have to make sure that each window remains active enough to prevent automatic log-off.

Is there a way to SSH in once and then piggy back on it with different terminal windows? (I use OSX and Ubuntu predominantly).

share|improve this question
up vote 4 down vote accepted

Screen and tmux offer you the answers you're looking for, but to expand your question a bit, I would like to suggest you look into the matter of SSH key-based authentication so that you don't need the username and password every time you SSH into your remote server :-)

share|improve this answer
Good point. It's generally more secure, too - see… – Randy Orrison Dec 11 '11 at 8:08
(I actually have moved over to key-based auth) – cwallenpoole May 29 '14 at 19:09

One other possible alternative is using sshfs.

sshfs lets you remotely mount any directory accessible on a remote machine through ssh, as a volume on your machine. Works great. The benefit here is that you can work with all the files on the remote machine as if they are local. Overall, it will be easier to use than screen - you login once, then anything else you do with the remote files will be just as if you are working with local files.

Your other alternative is just to use vim's ability to edit remote files over ssh. See here:

share|improve this answer

Not exactly what you asked for, but the GNU screen utility lets you have multiple virtual terminals in a single window. It also protects against connection disruption, because you can reconnect to a disconnected screen session.

share|improve this answer
It just might work. I'll have to try and see. – cwallenpoole Dec 10 '11 at 20:12

tmux is also an option (similar to GNU screen). It's code base is smaller and cleaner, it supports side-by-side panels without any extra messing around, and in my opinion it's a lot more pleasant to use. Screen is much more common though, so it's worth learning to use anyway.

To use tmux, just install it on the machine you want to SSH into. Then SSH in, run tmux, and you can now run multiple terminals or console apps on the same screen or in different 'windows' (analogous to Ubuntu workspaces) on the same terminal. Try man tmux for controls.

share|improve this answer

And another option is vim's built-in netrw plugin to open remote files. Works great with Project plugin.

But to be able to work with anything over ssh the first thing I do is to register my ssh key: ssh-copy-id user@host to register the key with the host and check ssh-agent is runing and add the key used with ssh-add.

I often do things like:

diffsplit scp://user@$REMOTE/path/to/dir/%

which diffs the file on $REMOTE host in ~user/path/to/dir with same relative name as current open file. I love vim, though I am sure it is possible in emacs too.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .