Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

So I have this school server that I am trying to connect to via nautilus. In terminal it's all easy but I want to be able to open it also in nautilus.

In terminal my way of doing it looks like this:


Now that I am connected in there, I can do ssh inside of that server to connect to server2. I canoot connect to server 2 directly. It has to be done like I do it right now.

So right now I can only get a connection to the first server in nautilus by typing ssh://

But how do I connect to the server2 from there?

share|improve this question
up vote 2 down vote accepted

If your first SSH server ( supports TCP Port Forwarding, you can forward a port on your local system (localhost) to via

ssh -fNL

This will forward port 2022 on localhost to port 22 on Then you can connect directly to the second server:

ssh myUser2@localhost:2022

In Nautilus, you can connect using ssh://myUser2@localhost:2022.

The -fN flags send SSH to the background, and creates a problem in closing it. There are three ways out:


ssh -fNL sleep 10

Now connect using Nautilus before the sleep command finishes executing (10 seconds). The connection will be kept alive as long as Nautilus is connected. When done, disconnect from Nautilus and the connection will be stopped.

Let the command wait for input

ssh -tL 'read -p"Press Enter to exit: "'

The read command will wait for input. Press Enter when you're done to close the connection.

Look up the connection process and kill it

pgrep -fa fNL

This will show you all processes which have fNL in the command line (there should only be your SSH connection process). Either kill the PID of the right process if there are more than one, or use pkill if there is only one process: pkill -f fNL This is pretty much the only option for connections that have already been established using -fN.

Run no command, and exit as usual

ssh -L

This will open a normal shell, from which you can exit as you normally do.

share|improve this answer
And after I am done, how do I close this port again? – Kaspar Sep 4 '14 at 7:57
@Kaspar I updated the answer. – muru Sep 4 '14 at 8:19
Thank you for the good answer! This solution works very well for me. – Kaspar Sep 4 '14 at 8:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.