Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

We can easily connect via ssh to the remote machine that has public IP.

But now I have a remote machine without public IP, and I need to connect to it from my machine that does have public IP. So that, remote machine should initiate this connection (add a client).

I need it because there is my grandfather on computer without public IP, and he needs help with his system sometimes.

In similar situation on Windows I've used VNC connection (by TightVNC), TightVNC server has an option "Add a client": user just entered client's IP (i.e. my public IP), my client is already in "listening mode", and when "server" adds a client, connection is initialized.

So, is it possible to perform the same trick with SSH connection?

share|improve this question
up vote 5 down vote accepted

By definition, the client is the one that initiates the connection.

For your problem, I think a simple solution would be building a reverse tunnel.

On the computer without public IP:

ssh -R 2222:localhost:22 loginOfServerWithPublicIP@publicIP

This connects to the server by SSH and builds a tunnel from the server with public IP on port 2222 to the computer without public IP on port 22 (SSH).

And then on the server:

ssh -p 2222 loginOfComputerWithoutPublicIP@locahost

The connection is redirected from the port 2222 of the server to the port 22 of the computer by the first tunnel. You may want to use tool like autossh to make the tunnel more resilient (i.e. restart it automatically when it shuts down).

share|improve this answer

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.