zoukankan      html  css  js  c++  java
  • 自建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成功

  • 相关阅读:
    P6406 [COCI2014-2015] Norma 分治+数学
    CF547D Mike and Fish 欧拉回路
    P6628 [省选联考 2020 B 卷] 丁香之路 欧拉路+最小生成树
    2020 CSP-S2 游记
    CF594D REQ 树状数组+质因数分解
    CF416E President's Path floyd
    CF1385F Removing Leaves 拓扑排序
    CF449C Jzzhu and Apples 思维题
    回溯法与八皇后问题
    codewars-7kyu:Sum of the first nth term of Series
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/13652721.html
Copyright © 2011-2022 走看看