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