• 自建git项目管理库及ssh方式使用


    下载地址:https://git-scm.com/downloads

     自建库后企业内部帐号与github帐号冲突,为了解决多个git帐号冲突,方法如下。

    步骤一:设置全局用户名,邮箱

    $ git config --global user.name "xxxx "
    $ git config --global user.email "xxxxx@xxxxxxx.xxxx"

    步骤二:生成ssh-keygen,示例如下

    $ ssh-keygen -t rsa -C "xxxxx@qq.com"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/SPB_Data/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in i:/git/xxxxx.
    Your public key has been saved in i:/git/xxxxx.pub.
    The key fingerprint is:
    xxxx  
       

    重复步骤一,二

    注意:可以不设置密码

    形成4个文件

     上传到带.pub的文件到自建git服务器上,位置如下

    本地git上传下载

    方式一:

    ssh-agent bash
    $ ssh-add "C:Userszgj.ssh生成的两个文件中的不带pub的那个"

    方式二:  

    去用户 /用户名 /.ssh 目录

    添加一个config文件,其他文件删除,config文件内容如下

    增加多个如下配置节

    Host gitlab.xxxx.com
    HostName gitlab.xxxx.com
    User zhaogaojian
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_xxxx

    注意:

    1、Host后面要填写实际打开git首页地址,比如gitlab.xxxx.com不能写成xxxx.com

    不然后面会一直access denied

    2、IdentityFile不要用那个带.pub的文件,.pub是公钥文件,需要上传到服务器上用。

    测试clone成功

  • 相关阅读:
    MySQL系列(三) MySQL的约束
    mysql 下载 国内 镜像
    ckeditor
    比较时间
    远程获取文件
    多线程一例
    requests
    json传递对象字典
    pymysql和mysqldb的区别
    sql
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/13652721.html
Copyright © 2020-2023  润新知