Question

Unable to update SSH RSA token on existing Droplet

Posted August 20, 2020 182 views
Ubuntu 18.04

I was following the tutorial on https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/ but when trying to add my key to the authorized_keys (droplet) it seems like the whole key is not getting copied and pasted from my windows system using PuttyGen to the Ubuntu console.

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.

×
1 answer

Hi, @CuteBlueRay

If you use the following command to copy your ssh key to the droplet are you getting any error messages or the command is executed without errors?

cat ~/.ssh/id_rsa.pub | \
ssh username@203.0.113.0 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Keep in mind you need to change 203.0.113.0 with your droplet IP address. Also keep in mind that you can check if the ssh key was copied okay using the DigitalOcean console within your account control panel.

Hope that this helps!
Regards,
Alex

  • Alex when trying to copy\paste the new generated RSA key into the authorizedkeys files the copy\paste is only partially getting the key into the file as I can see the end is not complete. Here is where I am at in the guide “nano ~/.ssh/authorizedkeys
    Copy
    Paste the contents of your SSH key into the file by right-clicking in your terminal and choosing Paste or by using a keyboard shortcut like CTRL+SHIFT+V. Then, save and close the file. In nano, save by pressing CTRL+O and then ENTER, and exit by pressing CTRL+X.”

    Where I copy\paste but I can see the RSA string is not completely copied into the file as it is missing the end. Looking at to see if it helps me: https://www.digitalocean.com/community/questions/copy-and-paste-into-console

    • Hi, @CuteBlueRay

      If you’re having issues to copy/paste the key you can temporary enable the password authentication to your droplet and copy the key using a ssh client like PuTTY or using the terminal.

      Once this is done you can again disable the PasswordAuthentication and connect using your ssh key.

      1. Login to the console on digitalocean website.
      2. Type sudo nano /etc/ssh/sshd_config
      3. Change PasswordAuthentication from “no” to “yes” and save the file
      4. Open a terminal on your computer and type ssh username@[hostname or IP address] or if on a Windows box use PuTTY for password login making sure authentication parameters aren’t pointing to a private key
      5. Login with password
      6. Type sudo nano ~/.ssh/authorized_keys
      7. Paste public key text here and save the file
      8. Type sudo nano /etc/ssh/sshd_config
      9. Change PasswordAuthentication from “yes” to “no” and save the file
      10. Log out and attempt to log back in (if using PuTTY make sure you set up auth parameters to point to your private key)

      Hope that this helps!
      Regards,
      Alex

Submit an Answer