Did you ever needed a simple connection to your home-server or a remote desktop to that Windows server at work? Most people would suggest to set up some expensive VPN hardware or other third party solution like LogMeIn but if you can reach that port 22 on the other side there’s some simple solution: ssh, the secure shell protocol
What do you need?
- a SSH-server listing on the other side
- a SSH client like PuTTY or just ssh in Ubuntu on your local machine
How does it work?
The basic idea is that you setup a local port on your local machine to forward a connection to a remote host port through the SSH connection.
1st example: connect to that Windows machine with remote-desktop
Just imagine that you want to connect to a Windows machine with remote-desktop (RDP) on your work or home. You could forward a port in your firewall rules at home, but most companies wouldn’t allow that and portforwarding wouldn’t work if you have dynamic IP adresses. Open up a console and type:
sudo ssh -L 3389:remote-windows-pc:3389 username@ssh-server
You will be prompted twice for a password, first your local sudo password and second the ssh password for the ssh-server. After the connection is established you can use your favorite remote-desktop client to connect to your localhost and you will see a Windows login screen from your remote machine.
2nd example: using PuTTY and Windows
If you’re restricted to Windows instead of Linux you can use PuTTY.
- Install putty. Download it here if you are using Windows. Debian or Ubuntu users can do an apt-get install putty
- Configure a basic connection (host and port).
- Go to Connections→SSH→Tunnels
- Add the configuration of the remote-desktop
- In source port, put 3389
- On destination, use the remote IP or hostname and the remote port (remote-ip:portnumber)
- Push the Add button
- Save your changes
- Connect to the server using PuTTY. You don’t need to be the root user on the remote server in this case
- Now use your remote-desktop client and connect to localhost
- You will see a Windows login screen from your remote machine
