Question

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

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?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.