Install SSH Key In A Remote Linux Server
I’ve been setting up a new server and as always the first things to do is forbid root login using a password and install my SSH keys. Once again I had to Google for how to do this, so I thought I would write about it instead.
After creating a new SSH key, if you don’t already have one, you can install it into the target computer using the
ssh-copy-id command to install you certificate directly onto the machine.
There are many ways to use the
nxad@desktop:~$ ssh-copy-id firstname.lastname@example.org nxad@desktop:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub email@example.com nxad@desktop:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub "firstname.lastname@example.org -p 4242"
- Create the SSH keys:
- (A) Install the public key:
nxad@desktop:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub email@example.com
- (A) I If you do not have ssh-copy-id installed on your PC this will also work:
nxad@desktop:~$ ssh firstname.lastname@example.org umask 077; mkdir .ssh nxad@desktop:~$ cat $HOME/.ssh/id_rsa.pub | ssh email@example.com cat >> .ssh/authorized_keys