该方法支持Ubuntu、CentOS等。
mkdir ~/.ssh chmod 700 ~/.ssh ssh-keygen -t rsa -b 4096cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys //append this key to the authorized_keys file.chmod 600 ~/.ssh/authorized_keys
编辑SSHD的配置文件/etc/ssh/sshd_config
,禁用密码,开启证书认证。
UsePAM no //if set no, MODT and landscape-sysinfo may have errors. PubkeyAuthentication yes PasswordAuthentication no
保存后重启服务sudo /etc/init.d/ssh restart
使用SSH登录的时候,编辑配置文件~/.ssh/config
Host hostname HostName 114.114.114.114User git IdentityFile ~/.ssh/git.rsa ServerAliveInterval 30