#ssh-keygen -t rsa #直接按 Enter即可
Generating public/private rsa key pair.
Enter file in which to save the key (/home/DEMO/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/DEMO/.ssh/id_rsa.
Your public key has been saved in /home/DEMO/.ssh/id_rsa.pub.
The key fingerprint is:15:44:64:ab:23:ca:0b:a1:66:98:5a:4a:83:c3:b4:93 DEMO@test
#這樣會產生 id_rsa和id_rsa.pub 二個檔案:前者是private key後者是:public key.
scp id_rsa.pub username@server_hostname:~/.ssh/ #把id_rsa.pub 放到您要連線電腦的帳號中的.ssh
#cat .ssh/id_rsa.pub >> .ssh/authorized_keys #到您要連線電腦的帳號中的.ssh 把public key加到authorized_keys 這個檔案.之後連線時, 就會用本機的 private key 與遠端電腦的 public key 做認證,這樣就不需輸入帳號密碼, 而且也比較安全.
沒有留言:
張貼留言