ssh-keygen 產生公鑰與私鑰對.ssh
ssh-copy-id 將本機的公鑰複製到遠程機器的authorized_keys文件中,ssh-copy-id也能讓你有到遠程機器的home, ~./ssh , 和 ~/.ssh/authorized_keys的權利ide
第一步:在本地機器上使用ssh-keygen產生公鑰私鑰對.net
- zhz@zhz:~/$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/zhz/.ssh/id_rsa):
- Enter passphrase (empty for no passphrase): [Press enter key
- same passphrase again: [Pess enter key]
- Your identification has been saved in /home/zhz/.ssh/id_rsa.
- Your public key has been saved in /home/zhz/.ssh/id_rsa.pub.
第二步:用ssh-copy-id將公鑰複製到遠程機器中get
- zhz@zhz:~$ ssh-copy-id -i .ssh/id_rsa.pub 用戶名字@192.168.x.xxx
注意: ssh-copy-id 將key寫到遠程機器的 ~/ .ssh/authorized_key.文件中it
第三步: 登陸到遠程機器不用輸入密碼io
- zhz@zhz:~$ ssh 用戶名字@192.168.x.xxx