I have had got a id_rsa key in my local machine which I used to connect to github. Now I wanted another keypair so that I could connect to bitbucket repository and another one for the digitalocean vps server.
For my DigitalOcean server I created a new key-pair using ssh-keygen and named it do_rsa so that it created two keys, do_rsa and do_rsa.pub, private and public key respectively.
Now the issue is if I try to connect using:
it gives Permission denied(publickey) error. This is because by default ssh client tries to read the id_rsa key pair values which is not the correct one. Actually I had assumption that my local ssh client would read all files in .ssh folder but this was not the case perhaps.
To make it work correctly we need to specify the correct private keyfile for the given IP address I have had for my digitalocean server. We can do it by creating a config file in the .ssh folder
So here is the content of the config file in .ssh folder
12 Host xxx.xxx.xxx.xxxIdentityFile ~/.ssh/do_rsa
After saving it I tried firstname.lastname@example.org and it worked like a charm!