zoukankan      html  css  js  c++  java
  • 创建和配置ssh keys for gitlab

    一、为gitlab.com建立ssh key

    • 建立本机的ssh publish key

    git config --global user.name "you name"

    git config --global user.email "aa@bb.com"

    • 生成ssh private key

    1.查看是否存在ssh private key: cd ~/.ssh,如果没有密钥则不会有文件夹,有就做好备份删除;

    2.生成密钥

    ssh-keygen -t rsa -C "aa@bb.com"

     按3个回车,密码为空;

    最后得到了两个文件:id_rsa和id_rsa.pub

    二、配置ssh客户端

    • 在gitlab.com上添加ssh密钥

    这里是添加id_rsa.pud里的公钥,打开gitlab.com,登录自已的账号,然后添加。

    • 配置config

    进入ssh目录:cd ~/.ssh/

    执行命令:sudo gedit config,打开文本后输入以下内容,注意Hostname的值是输入自已的,

    User git
    Hostname gitlab.yourwebsite.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    TCPKeepAlive yes
    IdentitiesOnly yes
    //如果你要走本地代理
    ProxyCommand nc -x 127.0.0.1:1080 %h %p

    保存与退出;

    • 测试是否成功

    ssh git@yourwebsite.com

    如果成功会显示:

    PTY allocation request failed on channel 0
    Welcome to GitLab, @youname!
    Connection to xx.com  closed.

    如果出现:the authenticity of host gitlab.com can't be established..

    请执行:

    eval $(ssh-agent -s)

    然后:

    ssh-add ~/.ssh/id_rsa

    参考此文章

  • 相关阅读:
    派生类的构造函数
    继承和派生
    自增自减运算符的重载(强制类型转换运算符重载)
    流插入和流提取运算符的重载
    动态数组类的设计
    函数的返回值
    赋值运算符的重载
    运算符重载
    常量对象函数引用和参数传递
    理解ASP.NET MVC的路由系统
  • 原文地址:https://www.cnblogs.com/johnnyzhao/p/10487921.html
Copyright © 2011-2022 走看看