Same traditional question but not very clear answer therefore I created a figure for clarification.

I want to connect to my office linux computer having vncserver installed and private ip from my home computer having vncviewer installed as shown in the figure. I also have a linux machine with public ip in the DMZ if that helps.

enter image description here

I am able to do it using teamviewer or chrome desktop. I am wondering if I can do it through it teamviewer and chrome desktop without any modification or port forwarding etc in router or any other computer than I should be able to do it myself too.

However it is not very straight forward.

I found something similar here but its not very clear.

My question is how can I connect to my office desktop by one click like when vncviewer connect to a remote computer on same network with vncserver installed?


  • You will most likely not be able do to this, it would mean adding a NAT rule in entry to your professional computer. That's mainly bad solution and terrible idea. Temaviewer is connecting a server and you don't connect to your PC directly but to teamviewer server and there's no incoming connection to your computer. If you need to access you professionnal laptop from outside ask your around you if there's a vpn or anything like that, don't use third party home made solution. Also what you propose with a VNC server is possible but don't do it if you don't understand how insecure this could be – Kiwy Apr 13 '18 at 8:16
  • Thanks for reply, but ssh tunnelling through my public ip server should be fine and secure. is'nt it? – Mian Asbat Ahmad Apr 13 '18 at 9:16
  • well mounting an reverse SSH tunnel on you server will most likely work, If you don't know how to do it, I couldn't advise you to do so. The tutorial you mention is in my opinion comprehensible and should allow you to succeed. Everything we could do here is rephrase it. – Kiwy Apr 13 '18 at 10:21
  • yes, but there both are client and server are mentioned as localhost and therefore I am a bit confused. Thats the main reason I clarified the localhost, middleserver and remote server. Could you please clarify the ssh commands used in the tutorial for my scenario – Mian Asbat Ahmad Apr 13 '18 at 11:15

Okay after some research I made it work. Let me explain clearly so it's not a problem for any one in the future having very common scenario like I have. In the above figure consider:

  • host_A my laptop in my home LAN
  • host_B my ssh server with public IP
  • host_C my Linux machine in LAN in my office.

To access desktop of host_C from host_A on the Mac, follow these steps:

  1. On host_A open terminal and run the command: ssh -t -L 5901:localhost:5901 user@host_B.net; after entering the password, you will be at host_B

  2. Now open another terminal and do: ssh user@host_B.net; give the password and then do: ssh user@host_C; give that password and you will be at host_C. Now run the command on host_C: ssh -t -R 5901:localhost:5901 user@host_B.net. That's it.

Now on the Mac, open finder, then click go menu and click connect to server. Type vnc://, give the password when requested, and you will get the desktop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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