SSH无密码登陆remote-host方法总结
项目使用的Git服务器是基于SSH的,又倡导小步提交,每天频繁的git pull代码和git push代码,每次都需要输入remote-host的密码很是麻烦,参考了网上的做法实验了一下无密码配置,将具体做法总结如下:
1,在local-host使用ssh-keygen命令生成ssh的公钥和私钥(不要设置密码,一路直接Press enter key)
local-user@local-host$ [Note: You are on local-host here]local-user@local-host$ ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/home/local-user/.ssh/id_rsa):[Press enter key]Enter passphrase (empty for no passphrase):[Press enter key]Enter same passphrase again:[Press enter key]Your identification has been saved in /home/local-user/.ssh/id_rsa.Your public key has been saved in /home/local-user/.ssh/id_rsa.pub.The key fingerprint is:d3:2a:75:b4:04:44:4c:27:44:54:89:4b:f4:68:13:32 local-user@local-host
cat /home/local-user/.ssh/id_rsa.pub | ssh remote-user@remote-host 'cat >> /home/remote-user/.ssh/authorized_keys'
ssh-copy-id -i /home/local-user/.ssh/id_rsa.pub remote-user@remote-host
cat /home/local-user/.ssh/id_rsa.pub | ssh remote-user@remote-server -p remote-port 'cat >> /home/remote-user/.ssh/authorized_keys'
sudo vi /etc/ssh/sshd_configPort 443 #增加443端口sudo reload ssh
sudo netstat -nlptu | grep :443
git config --local -eremote.origin.url=ssh://git@remote-host:remote-port/opt/git/project.git
cd /usr/binln -s /wls/devopr/git-ies/bin/git* .