1

I'm quite new to this, and I've looked through questions but haven't found one that quite matches my problem, or rather I didn't sufficiently understand them to be able to solve this issue.

I have a new server to which I can only access using a pre-generated SSH RSA key pair, which allows me to connect only to the default ubuntu user

ssh -i .ssh/mykey ubuntu@ipaddr

On the server I created a new user, newuser, and I'm trying to make it, so I can use my key that I connect to ubuntu on that account as well, but I'm not sure how to accomplish this, so I can then delete the ubuntu user.

ssh-copy-id -i .ssh/mykey.pub -o "IdentityFile .ssh/mykey" newuser@ipaddr

That though returns permission denied. How can I do this effectively? Any password login is disabled and can't be enabled in this instance.

1 Answer 1

1
  • ssh to your old user ubuntu
  • use sudo -i -u newuser to switch to the new user
  • open ~newuser/.ssh/authorized_keys with your favourite editor and copy&paste the content of your new public key into it
  • set proper permissions on the .ssh directory and the files inside it.

you may need to create the directory ~newuser/.ssh if it doesn't exist yet

1
  • 1
    Don't forget to give sudo access to your new user before you delete the old one. Feb 22 at 11:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .