First, use ssh-keygen to generate the public/private RSA key pair
willy@LOCAL_COMPUTER:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/willy/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/willy/.ssh/id_rsa. Your public key has been saved in /home/willy/.ssh/id_rsa.pub. The key fingerprint is: 8c:ee:fc:2f:62:b8:84:78:43:0b:1b:d7:7b:72:32:cd willy@willy-System-Product-Name The key's randomart image is: +--[ RSA 2048]----+ | | | | | | | . o | |o o . . S | | B o = | |o = *.E | | . o.Oo . | | .ooo.o. | +-----------------+
Second, copy the public key ~/.ssh/id_rsa.pub to the remote server
willy@LOCAL_COMPUTER:~$ sftp willy@REMOTE_SERVER sftp> put id_rsa.pub sftp> quit
Third, login the REMOTE_SERVER and append the id_rsa.pub to ~/.ssh/authorized_keys
willy@LOCAL_COMPUTER:~$ ssh willy@REMOTE_SERVER willy@REMOTE_COMPUTER:~$ cat id_rsa.pub ~/.ssh/authorized_keys willy@REMOTE_COMPUTER:~$ exit
Finally, login again, this time, we need not to enter the password.
No comments:
Post a Comment