So you finally did it! You have a remote Linux server. Welcome to the other side of the world 😆 Please seat tight as we send you a crate of soda, a pack of gum and T-shirts with weird writings. It is written on the ancient scrolls that every living geek must have a combination of these.
Remote Linux-ing is super fun and you get to learn about ssh and all the super CLI stuff. Plus, ssh (especially used with Authentication keys) helps keep you safe. The honeymoon ends when you want to use a GUI. Of course you can’t use ssh for that so you go to another software like VNC which is okay except is not as secure as ssh.
If you are an admin of a busy server, you will bear me witness that attacks come in the thousands of trial times and having weak links is not good for your sleep. So how can you use VNC securely?
Pretty simple really. Just tunnel it through an ssh connection.
It’s actually a one command thing: $ssh -L <port>:localhost:<port> -N -f -l <user> <IP>
Example: $ssh -L 5900:127.0.0.1:5900 -N -f -l ninjadmin 18.104.22.168
The command above creates a tunnel for VNC to connect through. As you can see, this is an ssh connection so you’re as safe as needs to be.
After you’are done, launch VNC and you will get a prompt.
Enter the IP and port as follows: 127.0.0.1:<port>
Click connect and you’re good to go!
Note: You have to have allowed the VNC ports in through your firewall if you have any.