通过SSH认证连接GIT


通过SSH认证连接GIT
 
一,连接权限认证
         有多种办法可以连接到GIT服务器,以获取或提交资料,主要包括
1.        每个开发者建立账账户。
2.        SSH公钥认证。
3.        集中授权,然后与SHELL访问权相同。
  www.2cto.com  
二,生成公钥
         为了方便使用(就是不用账户什么的东西),我们所有的项目都用SSH公钥进行认证,
所以我们的第一步骤是产生公钥。
 
命令是:ssh-keygen -C"maoxiang@pachiratech.com" -t rsa
 
执行和输出结果如下:  www.2cto.com  
 
[root@localhost .ssh]$ ssh-keygen -C"xxx@qq.com" -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key(/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in/root/.ssh/id_rsa.
Your public key has been saved in/root/.ssh/id_rsa.pub.
The key fingerprint is:
d2:5f:a7:c4:fa:66:1d:b8:64:49:31:03:e5:d8:3b:6exxx@qq.com
The key's randomart image is:
+--[ RSA 2048]----+
|         .o.    |
|          ++    |
|         . o+   |
|      .   ...   |
|     . S  .*o.  |
|      . . ==+.  |
|         ooEo . |
|          o+ .  |
|          o.    |
+-----------------+
[root@localhost .ssh]$ ls
id_rsa id_rsa.pub
[root@localhost .ssh]$
执行完这个命令后,在/root/.ssh/目录有两个文件,这两个文件就是私钥和公钥文件,英文称之为keypair。
接下来只需要把这两个文件中的公钥文件加到GIT用户的authorized_keys文件之中就可以了(这一步可把该文件发送给GIT管理员)。在这之后,就可以通过SSH认证的方式连接远程的GIT服务器了。也就是你可以直接执行git相关的命令了
 

相关内容

    暂无相关文章