Yes, just edit the
/etc/hosts file and add them.
You would add the IP of the Droplet and then a name separated by a whitespace:
And the you can easily do what you need:
But maybe you’d prefer to configure a SSH config file instead?
For example, you could edit your
~/.ssh/config on the specific Droplet and add them individually:
That way you can just do:
And the SSH configuration will automatically connect with the right credentials as configured.
If you use the same SSH key for every Droplet, you don’t have to add your SSH key to the Droplet, but can add it to your local machines SSH config and remove the
IdentityFile ~/.ssh/id_rsa line from your Droplets SSH configuration. To your local SSH configuration you could do:
ForwardAgent yes which means that your SSH key will be forwarded in your SSH connection. Just remember to add it to your SSH Agent (pagent for Putty, ssh-add for others) or the forwarding won’t work.