Do I have to give location to SSH key everytime I login via SSH?

September 6, 2018 447 views
Security Ubuntu 16.04

Hi I just set up ssh keys using openssh and added them to my droplet following the guides. The ssh keys have been saved in a non-default folder on my computer. During my first login via ssh I used the command

ssh -i /path/to/private/key username@203.0.113.0

I was asked to enter my passphrase and upon entering it given access. All good till here.

Now the second time I logged in, I enterered

ssh username@203.0.113.0

But this did not log me in directly.

So I had to use just like the first time

ssh -i /path/to/private/key username@203.0.113.0

and enter my passphrase.

Is this normal and happening because my SSH key is in a non-default folder? Or am I doing anything wrong?

1 Answer

One way would be to add your public keys to your Digital Ocean account (in the Security tab https://cloud.digitalocean.com/account/security). Then when you create your droplet, you can reference these by the ID. API ref: https://developers.digitalocean.com/documentation/v2/#create-a-new-droplet.

Have another answer? Share your knowledge.