SSH 公钥访问 git 仓库

服务端

修改 /etc/ssh/sshd_config 目录

RSAAuthentication yes   
PubkeyAuthentication yes   
AuthorizedKeysFile .ssh/authorized_keys

针对用户 git 中创建 authorized_keys

$ cd /home/git/
$ mkdir .ssh
$ chmod 700 .ssh
$ touch .ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys

注意「权限」一定不能少

将公钥复制到authorized_keys中,「客户端」使用 git 用户进行 ssh 连接 以及 git 克隆/拉取/推送 都不需要密码操作

参考URL

http://blog.51yip.com/linux/1838.html
https://juejin.im/post/5a2696fcf265da43305e5423

你可能感兴趣的:(SSH 公钥访问 git 仓库)