-1

I have to work on an issue happening on a server running Arch Linux. The other dev sent me an e-mail with the key to access as the root user and wrote me this "You should login as root, upload your public ssh key and add it to the authorized_keys of the xxx user".

He created a user to run a node application. I have the public key file and I need to add it to the authorized_keys of the user he uses to run the app, so I can ssh as this user.

My problem is that I don't know the command to do it. I would like to know how to do it with a file in my local machine or just copy the authorized_keys from the root.

  • Open up ~/.ssh/authorized_keys in an editor and append the SSH key there. There are plenty of tutorials around the internet for this kind of thing, please check those out before asking here. – 0xdd Sep 27 '18 at 14:23
4

Send your key to /tmp then append it to authorized_keys.
Replace SERVER and USER in these commands:

scp ~/.ssh/id_rsa.pub root@SERVER:/tmp/id_andre_luiz
ssh root@SERVER
cat /tmp/id_andre_luiz >> ~USER/.ssh/authorized_keys
1

I do it like this:

cat <your_public_key_file> >> ~/.ssh/authorized_keys

Note the double > without the double > the existing contents of authorized_keys will be over-written (nuked!) and that may not be desirable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.