Question

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

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/fXXXX_rsa.pub | 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 ?


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.

Hello,

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.