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 email@example.com nxad@desktop:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub firstname.lastname@example.org nxad@desktop:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub "email@example.com -p 4242"
- Create the SSH keys:
- (A) Install the public key:
nxad@desktop:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub firstname.lastname@example.org
- (A) I If you do not have ssh-copy-id installed on your PC this will also work:
nxad@desktop:~$ ssh email@example.com umask 077; mkdir .ssh nxad@desktop:~$ cat $HOME/.ssh/id_rsa.pub | ssh firstname.lastname@example.org cat >> .ssh/authorized_keys