在未添加公鑰時, 克隆需要密碼輸入, 再編輯目錄下創建公鑰后就可以不用輸入密碼
在創建的目錄輸入創建公鑰命令 可以在計算機C:\Users\Administrator\.ssh 看到倆個文件
ssh-keygen -t rsa -C "358033733@qq.com"
創建完成后,
⑥ 服務器端 Git 打開 RSA 認證
進入 /etc/ssh 目錄,編輯 sshd_config,打開以下三個配置的注釋:
RSAAuthentication
yes
PubkeyAuthentication
yes
AuthorizedKeysFile .
ssh
/authorized_keys
保存並重啟 sshd 服務:
[root@localhost
ssh
]
# /etc/rc.d/init.d/sshd restart
[root@localhost git]
# pwd 此git目錄就是你創建的遠程git庫
/home/git
[root@localhost git]
# mkdir .ssh
[root@localhost git]
# ls -a
. .. .bash_logout .bash_profile .bashrc .gnome2 .mozilla .
ssh 在添加.ssh 后 git 目錄中也必要有其他的文件
[root@localhost git]
# chown -R git:git .ssh
[root@localhost git]
# ll -a
總用量 32
drwx------. 5 git git 4096 8月 28 20:04 .
drwxr-xr-x. 8 root root 4096 8月 28 19:32 ..
-rw-r--r--. 1 git git 18 10月 16 2014 .bash_logout
-rw-r--r--. 1 git git 176 10月 16 2014 .bash_profile
-rw-r--r--. 1 git git 124 10月 16 2014 .bashrc
drwxr-xr-x. 2 git git 4096 11月 12 2010 .gnome2
drwxr-xr-x. 4 git git 4096 5月 8 12:22 .mozilla
drwxr-xr-x. 2 git git 4096 8月 28 20:08 .
ssh
回到 Git Bash 下,導入文件:
1
|
$
ssh
git@192.168.56.101 'cat >> .ssh/authorized_keys' < ~/. ssh /id_rsa .pub
回到服務器端,查看 .ssh 下是否存在 authorized_keys 文件:
|