Navigate back to the homepage

VSCode Remote SSH

Frédéric De Smet
December 1st, 2020 · 1 min read

I think everyone by now knows the remote plugin for vscode.

If not, you can install it here:

vscode-remote-ssh-install

With the Remote - SSH extension installed, you will see a new Status bar item at the far left.

remote-status-bar

Handy features

Configuration file

If you log in to multiple remote servers or local virtual machines on a regular basis, there’s a better way to connect without having to remember all the usernames, addresses, and additional configuration options.

To use an SSH config file, click on the remote indicator to bring up the remote commands, choose Open Configuration File, and select the file that follows the path “Users/{yourusername}/.ssh/config”.

"Remote-explorer"

1# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
2Host python-linux-vm
3 HostName <vm address>
4 User sana
5 IdentityFile ~/.ssh/id_python_vm
6
7Host node-vm
8 HostName <vm address>
9 User sana
10 Port 5522
11 IdentityFile ~/.ssh/id_node_vm

Once you’ve saved the config file, you’ll be able to see those hosts in the Remote Explorer

"Remote-explorer"

Proxy

Sometimes you may need to connect from your desktop or laptop to a remote machine over your company’s Intranet or behind a firewall. In this case, you may be using an intermediate server or jump box. This kind of setup is useful if you are working within a secure system that is configured to only accept SSH connections from a fixed set of hosts.

To use a jump-box setup with the Remote - SSH extension, you can use the ProxyCommand config option. This configuration will open a background SSH connection to the jump box, and then connect via a private IP address to the target.

You can set the ProxyCommand config option in the SSH config file like this:

1# Jump box with public IP address
2Host jump-box
3 HostName 52.179.157.97
4 User sana
5 IdentityFile ~/.ssh/jumpbox
6
7# Target machine with private IP address
8Host target-box
9 HostName <IP address of target>
10 User sana
11 IdentityFile ~/.ssh/target
12 ProxyCommand ssh -q -W %h:%p jump-box

More articles from blog by Frédéric De Smet

Tips and tricks for passing the CKA exam

This article is about how I passed the certified Kubernetes Administrator (CKA) exam

November 8th, 2020 · 1 min read

My first post

I'll be starting my own blog. This will be a catalog of everything I've learned over the years. Maybe this could be an interesting blog in the end. Or not we'll see!

September 15th, 2020 · 2 min read
© 2020–2021 blog by Frédéric De Smet
Link to $https://twitter.com/dsfrederic_Link to $https://github.com/dsfredericLink to $https://instagram.com/dsfredericLink to $https://www.linkedin.com/in/dsfrederic/