第一次使用Gitlab上的issues进行缺陷管理,在使用是出现You won't be able to pull or push project code via SSH until you add an SSH key to your profile (在您的配置文件中添加一个ssh密钥之前,您将无法通过ssh来拖动或推动项目代码):
解决办法:首先确保电脑上安装了git:
详细教程请看我的博客园 :https://www.cnblogs.com/gufengchen/p/10989312.html
当git 安装好后:
1、在git中输入命令:$ cd ~/.ssh 检查是否生成过KEY,
没有生成过key
如果显示有id_rsa.pub或者id_dsa.pub存在,直接进入第4步开始
2、在git中输入命令:$ ssh-keygen -t rsa -C “你公司在GITLAB上的邮箱地址”,按下回车键:这个命令是生成key命令的
3、直接会车,不输入命令
4、找到:生成的key目录
5、在GITlab上添加key:登陆gitlab网站:点击账号--点击Settings--点击SSH KEYS
6、然后把刚才目录文件中的生的id_rsa_pub中的密钥全部粘贴如:keys中--点击add keys搞的
结束:
一下是我的详细步骤及完整图片:
longximg@longximg-PC MINGW64 ~/Desktop
$ cd ~/.ssh #查看ssh文件是否存在
bash: cd: /c/Users/longximg/.ssh: No such file or directory
longximg@longximg-PC MINGW64 ~/Desktop
$ ssh-keygen -t rsa -C "isaac.zhu@dbappsecurity.com.cn" #邮箱为公司的gitlab邮箱,生成KEY
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/longximg/.ssh/id_rsa): //密钥的目录
Created directory '/c/Users/longximg/.ssh'.
Enter passphrase (empty for no passphrase): //密码设置为空
Enter same passphrase again:
Your identification has been saved in /c/Users/longximg/.ssh/id_rsa.
Your public key has been saved in /c/Users/longximg/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:26He3Khz3tI1hREYImxaUoJny4FzzaQvevdeZlIrB8M isaac.zhu@dbappsecurity.com.cn //公钥
The key's randomart image is:
+---[RSA 3072]----+
| o.*+ . .o.. |
| + *o*. .. . |
| *.B o |
| +. . . .|
| . S E . . |
| . . + = .o |
| . . + +.*. . |
| . o.+o@. |
| o*B.o |
+----[SHA256]-----+
longximg@longximg-PC MINGW64 ~/Desktop
$ cd ~/.ssh //在次查看是否生成了ssh文件
longximg@longximg-PC MINGW64 ~/.ssh
$ ls -a //显示ssh文件下的密钥文件
./ ../ id_rsa id_rsa.pub
longximg@longximg-PC MINGW64 ~/.ssh
$ cat id_rsa.pub //打开id_rsa.pub文件,复制密钥
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC2bTU4NsV2xNR1l9d8C6cKGXBsV7aPnN2ZFJJstfw0PGD3OeSWk666G5WtmJq0f//XHFxbiEjgNW8OrIwPRrxzHlOMQGwAAxyunBSq+j/eITjykWQMJRNlgNrXD0XpOBxjpv8Y8g0/ChUR5Lqtpwt46RfTArFJv2NGNoAEcYpaU//rNQtWy9LGgWp7sUgoyqMycQVDG03ZoaqyJAibDVb3TALSjadcbaw21DKdvFRR0WyS7bneu4pNDjKnmk0OB5F6kEpjMti9eFaIFXAT0ZIkCfsNFP8dccHduQ4HD9u4VM+Kf+CpfJurp/vsB4/MuMiDhUg3AUheSPE0FYKzOGRIXhY3/1VIu+6Xeh/vLT5GAJ7LnDEtgNXn2LSK9aVakcM+Zy6/g3EFslERIfI9sg1cpvep0LBdaM2e0/O0YA5/QSAJZ9mg/bt+KWnK3XiB8XdNveX8p0C0ULx0pZfw18QYCi1xAnBCQ+8QP7520r2DBqEIcabzWP3K55yTWMVRK+0= isaac.zhu@dbappsecurity.com.cn
longximg@longximg-PC MINGW64 ~/.ssh
$ /*到这一步已经获得了SSH秘钥了可以添加到git上了*/
longximg@longximg-PC MINGW64 ~/.ssh
#使用账号duxiaolei 密码:Duia_duxiaolei 登录git.duia.org.cn
#将上面生成的ssh 添加进去:
(以上是实际操作截图)
教程:
cd ~/.ssh
# 生成rsa密钥,密钥秘钥:123456
ssh-keygen -t rsa -C "xxx@gmail.com”
# 将密钥文件复制到剪贴板
pbcopy < ~/.ssh/myname_rsakey.pub
# 进入github,设置ssh密钥
# 1. Edit Profile
# 2. SSH Keys
# 3. Add SSH Key
# 4. 将刚刚复制的Key粘贴,然后提交
# 添加rsa密钥
ssh-add myname_rsakey
# 测试github连接
ssh -T git@github.com
# 关联项目
cd 项目文件夹/
# 为当前文件夹初始化git
git init
# 添加远程服务器
git remote add origin git@github.com:liufan321/HelloWorldDemo.git
# 从服务器拉项目
git pull -u origin master
# 将项目内容推送到服务器
git push -u origin master
————————————————
版权声明:本文为CSDN博主「白清羽」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/gufenchen/article/details/95663284