SSH Keys
From NippAero
The ssh keys are usually stored in /root/.ssh/. The local key pair is named id_rsa.
Contents |
Generate first ssh key
Type the following command to generate your first public and private key on a local workstation. Next provide the required input or accept the defaults. Please do not change the filename and directory location.
linux01:~/.ssh # ssh-keygen -t rsa -b 1024
Copy your public key to your remote server
Use scp to copy the key you just made to the remote linux box. Be sure to rename it to another name and not overwrite the remote copy.
linux01:~/.ssh # scp id_rsa.pub root@linux02://root/.ssh/linux01.pub
Append the public key to Authorized Keys file
On the remote server, cat the file you just copied to the local authorized key file.
cat linux01.pub >> authorized_keys
Generate next ssh key
On the remote machine generate the local/public keys if not already generated.
linux02:~/.ssh # ssh-keygen -t rsa -b 1024
Copy remote public key to your linux box
Use scp to copy the key you just made on the remote linux box to yours. Be sure to rename it to another name and not overwrite your own copy.
linux02:~/.ssh # scp id_rsa.pub root@linux01://root/.ssh/linux02.pub
Append the public key to Authorized Keys file
On your server, cat the file you just copied from the remote server to your local authorized key file.
cat linux02.pub >> authorized_keys
Test your Setup
From your server to the remote.
linux01:# ssh linux02 Last login: Tue Oct 9 20:52:36 2007 from linux01.domain.com [root@linux02 ~]#
From the remote server to your local box.
[root@linux02 ~]# ssh linux01 Last login: Tue Oct 9 14:52:38 2007 from lnx02.domain.com Have a lot of fun... linux01:~ #
