设置步骤:
1,本地进入.ssh查看是否存在密钥对:xxx和xxx.pub
命令:cd ~/.ssh
2,如果不存在,使用ssh-keygen来创建
命令:ssh-keygen -t rsa -C "youremail@youremail.com"
例如:ssh-keygen -t rsa -C "wanwan5856@163.com"
注解:
Enter file in which to save the key 输入保存秘钥的文件 直接enter即可
Enter passphrase (empty for no passphrase) 输入密码 直接enter即可
此时查看.ssh目录下可看到新增的一对秘钥id_rsa和id_rsa.pub
3,查看公钥
命令: cat ~/.ssh/id_rsa.pub
复制全部,包括后面的邮箱
4,添加到gitlab中
左侧栏Profile Settings → 左侧栏SSH Keys → 粘贴并Add key
5,创建config,端口为22可忽略这一步
命令:cat>~/.ssh/config
输入:
Host gitlab.xxx.com
User git
Port 458
IdentityFile /home/yourname/.ss
访问gitlab从http方式改为ssh方式,gitlab使用的不是标准22端口
最新推荐文章于 2024-05-28 11:00:28 发布