SSH is an integral part of a software engineer's day to day activity. You can use SSH commands to connect to a remotely hosted machine over the internet or a local network. The normal way to connect to a machine is using this syntax:
ssh -i identityfile.pem username@hostname
You could also use a password. There's always a hassle to type this complete command, so you might want to abstract it to an alias in your ~/.bashrc or ~/.bash_profile file like this:
alias vm="ssh -i ~/linuxmachinekey.pem linuxuser@192.168.0.1"
If you have multiple virtual machines, you have to create multiple aliases. What if there was an easier way? Good news! There is an easier way. This is the SSH configuration file: ~/.ssh/config
. You define the properties of your SSH connection in this file in this fashion:
Host LinuxVM
HostName 192.168.0.1
User linuxuser
IdentityFile ~/linuxmachinekey.pem
Host KaliVM
HostName 192.168.20.1
User kali
IdentityFile ~/kali.pem
You then connect to the VM in this fashion:
ssh LinuxVM
# or
ssh KaliVM
No need for typing IP addresses and the likes.
You also get to easily connect to a remote VSCode instance with this configuration using VSCode Remote SSH.