ssh-key on already existed droplet

December 9, 2014 1.1k views

If I have already created my droplet, how can I add ssh-key to it?

3 Answers

You simply need to paste the contents of your public key into the ~/.ssh/authorized_keys file on the server. On a Mac or Linux computer, you can send your key to the server with this one command:

cat ~/.ssh/ | ssh username@server.ip.addr "mkdir -p ~/.ssh && cat ~/.ssh/authorized_keys"

For all the details, check out this tutorial:

SSH, or secure shell, is the most common way of administering remote Linux servers. Although the daemon allows password-based authentication, exposing a password-protected account to the network can open up your server to brute-force attacks. In this guide, we demonstrate how to configure your server with SSH keys, which is the recommended authentication method. These are much more difficult for attackers to work around, giving you a more secure login mechanism.
  • @asb
    suppose i need to give access to console to my developer, then ill give him the public key. but how he will login using public key using putty? will he use public key as private key in putty console?

  • @newbie In most cases, your developer should generate their own public/private key pair. They'd then give you their public key to add to the server.

you didnt get me buddy, i hire various freelancer time to time for individual work in my server. and i need to give me my password for root access. what should i do in this case? isnt there any way to secure my server by giving them a sort of access by which they cant bring harm if they want?

also, i can add ssh key to my droplet by deploying from snapshot. correct?

Have another answer? Share your knowledge.