• 创建和配置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

    参考此文章

  • 相关阅读:
    一些手打的笔记
    字符集的相关知识
    Java的概述以及语法
    Java和eclipxe的安装以及第一个程序
    制作Html标签以及表单、表格内容
    2,8,10,16进制之间的转换
    验证日期时间
    验证输入一个月的31天
    验证输入一年的12个月
    身份证号验证
  • 原文地址:https://www.cnblogs.com/johnnyzhao/p/10487921.html
Copyright © 2020-2023  润新知