生成公开密匙文件 git@android:~$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/git/.ssh/id_rsa): Created directory '/home/git/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/git/.ssh/id_rsa. Your public key has been saved in /home/git/.ssh/id_rsa.pub. The key fingerprint is: 7e:fd:c6:0a:d3:37:53:bd:e9:ac:fd:b2:31:ba:ea:0d git@android The key's randomart image is: +--[ RSA 2048]----+ | | | | | | | .| | S o| | . o .o| | . E o.*o | | . = +B= | | .o.==+*o| +-----------------+ 把其他一个用户的公匙加入到下面这个文件 git@android:~$ cat /tmp/yuanwei.pub >> .ssh/authorized_keys
验证是否生效
yuanwei@android:/home/gitolite/repositories$ ssh git@192.168.2.128 Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-26-generic x86_64) * Documentation: https://help.ubuntu.com/ The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. git@android:~$ exit 登出 Connection to 192.168.2.128 closed. yuanwei@android:/home/gitolite/repositories$