Add a public ssh key to the authorized_keys of a user

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












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. Can you help me?










share|improve this question























  • 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.
    – Jules
    Sep 27 at 14:23















up vote
0
down vote

favorite












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. Can you help me?










share|improve this question























  • 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.
    – Jules
    Sep 27 at 14:23













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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. Can you help me?










share|improve this question















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. Can you help me?







ssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 27 at 17:31









jasonwryan

47.6k14131180




47.6k14131180










asked Sep 27 at 14:17









André Luiz

1063




1063











  • 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.
    – Jules
    Sep 27 at 14:23

















  • 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.
    – Jules
    Sep 27 at 14:23
















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.
– Jules
Sep 27 at 14:23





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.
– Jules
Sep 27 at 14:23











2 Answers
2






active

oldest

votes

















up vote
4
down vote



accepted










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





share|improve this answer






















  • Thanks you for the answer!
    – André Luiz
    Sep 27 at 14:34

















up vote
1
down vote













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.






share|improve this answer


















  • 1




    Thank you for the answer!
    – André Luiz
    Sep 27 at 14:34










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471837%2fadd-a-public-ssh-key-to-the-authorized-keys-of-a-user%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
4
down vote



accepted










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





share|improve this answer






















  • Thanks you for the answer!
    – André Luiz
    Sep 27 at 14:34














up vote
4
down vote



accepted










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





share|improve this answer






















  • Thanks you for the answer!
    – André Luiz
    Sep 27 at 14:34












up vote
4
down vote



accepted







up vote
4
down vote



accepted






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





share|improve this answer














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






share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 27 at 14:41

























answered Sep 27 at 14:31









user285259

3407




3407











  • Thanks you for the answer!
    – André Luiz
    Sep 27 at 14:34
















  • Thanks you for the answer!
    – André Luiz
    Sep 27 at 14:34















Thanks you for the answer!
– André Luiz
Sep 27 at 14:34




Thanks you for the answer!
– André Luiz
Sep 27 at 14:34












up vote
1
down vote













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.






share|improve this answer


















  • 1




    Thank you for the answer!
    – André Luiz
    Sep 27 at 14:34














up vote
1
down vote













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.






share|improve this answer


















  • 1




    Thank you for the answer!
    – André Luiz
    Sep 27 at 14:34












up vote
1
down vote










up vote
1
down vote









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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 27 at 16:17









Rui F Ribeiro

36.9k1273117




36.9k1273117










answered Sep 27 at 14:31









Shervan

1889




1889







  • 1




    Thank you for the answer!
    – André Luiz
    Sep 27 at 14:34












  • 1




    Thank you for the answer!
    – André Luiz
    Sep 27 at 14:34







1




1




Thank you for the answer!
– André Luiz
Sep 27 at 14:34




Thank you for the answer!
– André Luiz
Sep 27 at 14:34

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471837%2fadd-a-public-ssh-key-to-the-authorized-keys-of-a-user%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)