1. 生成公钥
ssh-genkey 在window 端git-bash中执行,如果没有安装git就安装一个widnow git
- 输入命令后,提示需要内容,全部不管,回车即可。后面会提示你密码的:
2. 将公钥添加到linux server 端
-
方式1 : 直接复制
scp -P 22 id_rsa-remote-ssh.pub phoenix@192.168.81.128:~/.ssh/
-
方式2 : 工具命令复制
ssh-copy-id -i .ssh/id_rsa.pub 用户名字@192.168.x.xxx
添加完成 。
`
$ ssh-copy-id -i .ssh/id_rsa.pub ll@192.168.3.2
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
lin@192.168.3.2's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'll@192.168.3.2'"
and check to make sure that only the key(s) you wanted were added.
`