Mar 8, 2013

SSH: using specific keys with specific hosts

First of all, I have never thought I'd post something Unix related (not that I have anything against it; it just because I am more a Windows user :)

It just happens that for personal reasons I have some VMs running Ubuntu and from time to time I need to transfer files from my host computer to the guest, i.e, from my Windows machine to Ubuntu running on the VM. Since the virtualization solution I am using has some issues regarding file/folder sharing between host/guest OS, I am using scp to do the job.

Until today I used to have a single RSA key pair to authenticate me when connecting to my Ubuntu VM and also to github and bitbucket but this has proven to no be an optimal solution. You see, when I am copying files to Ubuntu I'd like to not be forced to type any password, after all this VM has no sensitive data and is off limits since it is not connected to the internet, but since I am using a single RSA key pair for most of my authentication  needs I don't want do leave it unprotected so every time I want to copy something to the guest OS (my Ubuntu running on the VM) I find myself typing a huge, complicated password - actually very often mistyping it :(.


Today I took the time and decided I'd find out how to setup multiple RSA key pairs and use one with no password at all to authenticate me with my VM and one with a strong password for each online service I use.


Actually it was easier than I thought ;). Basically the utilities I rely on (ssh and scp) allows one to specify which identity file (the RSA file containing your private key) (-i file_path) is to be used.


if you don't want to specify which file should be used every time or if the utility you use don't allow you to specify this file (but uses ssh behind the scenes) you can use ~/.ssh/config file!

Happy codding.

No comments: