How to add a second SSH key so another user connects to SFTP?

May 29, 2015 493 views
DigitalOcean Getting Started

I have been able to connect to SFTP with my own key, but I want my client to have access to SFTP too. I made a key pair for him and added the public key to Digital Ocean. I tried to add the public key with the command sudo ssh-keygen -e -f ~/.ssh/ | sudo tee /etc/proftpd/authorized_keys/fXXXX after adding the public key in the ~/.ssh directory, but it didn't work – asked for a passphrase while the key didn't have one.

Could someone help me on this ?

1 Answer


The SSH keys added through the control panel are used only when creating droplets. To get things working on an existing droplet you just need to add the public key to the ~/.ssh/authorized_keys file.

This file contains a line for each public SSH key you want to add. So I recommend doing the following.

If you have password authentication enabled, run the following command on the client computer that has the key pair.

ssh-copy-id -i /path/to/key user@ip.address

It will ask you to log in with your password, then copy the key. Make sure to update /path/to/key to the path to your private key. user@ip.address should be replaced with the user you want to use and the ip address of your droplet.

If you do not have password authentication enabled, you can manually log into SSH with a user that has access and open the authorized keys file with:

nano ~/.ssh/authorized_keys

Then start on a new line and copy the public key below whatever keys you already have.

Then hit Ctrl + x and then y to accept changes. Then the user can log in with their SSH key.

Have another answer? Share your knowledge.