1.ssh 利用rsa pubkey访问,无需密码登录服务器
使用Secure Shell Client客户端,在Edit->settings->Keys可以生成密钥对,将公钥上传至服务器。
将window ssh 转换成openssh 认识的格式
ssh-keygen -i -f id_rsa.pub >>/root/.ssh/authorized_keys
修改服务器sshd配置
vi /etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysFile ~/.ssh/authorized_keys
重启服务器sshd服务
使用客户端重新登录
2.rsa pubkey配置GIT
openssh 生成密钥对
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
将公钥配置到git提供的配置页面即可。
gitbash 测试是否连接成功,成功将返回successfully等信息。
ssh -Tv git@github.com
当同时使用多个平台的git时,将有多个密钥对,需要一个config进行配置
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_rsa
Host git.oschina.net
HostName git.oschina.net
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa