Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto add your ssh public key to the authorized_keys files?

Tags:

linux

ssh

I am looking for the simplest set of commands you can run for adding your public key to the authorized_keys files of the root account on a remote server.

We assume that the current user has login access to the remote server and it is also listed in the sudoers file.

Running the command twice should have no effect.

like image 792
sorin Avatar asked May 15 '12 08:05

sorin


People also ask

How do I generate SSH key automatically?

Generating a SSH keyNavigate to the Triton Portal and open the Account Summary. From the SSH section, select Create SSH Key. In the Create SSH Key dialog, enter a Key Name and then select Create Key. The private and public SSH key pairs generate.

Where do I put SSH public key?

You need to be able to transfer your public key to the remote system. Therefore, you must either be able to log into the remote system with an established account username and password/passphrase, or have an administrator on the remote system add the public key to the ~/. ssh/authorized_keys file in your account.


1 Answers

How about running the ssh-copy-id command? Man pages says the following:

ssh-copy-id - install your public key in a remote machine's authorized_keys

Sounds exactly what you're looking for? I have never tried running the command twice, though. It may not check for that.

like image 169
Ray Avatar answered Nov 15 '22 06:11

Ray