码云(gitee)配置ssh密钥
创建公钥的目的: 使用SSH公钥可以让你在你的电脑和码云通讯的时候使用安全连接(git的remote要使用SSH地址)
步骤:
打开终端(git)进入.ssh目录
输入 cd ~/.ssh进入ssh 如果.ssh文件夹不存在,执行指令自动创建 mkdir ~/.ssh(已经创建了,会提示文件已存在)
[root@i-root ~]# mkdir ~/.ssh
mkdir: 无法创建目录"/root/.ssh": 文件已存在
[root@i-root ~]# cd ~/.ssh
生成RSA密钥对,输入下面命令直接几次回车
ssh-keygen -t rsa -C “你的邮箱@xxx.com”
0eat[root@i-root .ssh]# ssh-keygen -t rsa -C "xxx@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:sG+CQbcCNVMpky2dUhKnnfuuBoGtjnSbhTmLASc0/h4 xxx@qq.com
The key‘s randomart image is:
+---[RSA 2048]----+
| *B+o |
| o .*B=. |
|o ooo== |
|o.ooo. = |
|.o..=.+ S |
| o.E.= o |
|.o= O.. + |
|...= .+ |
| .... |
+----[SHA256]-----+
生成成功
3. 查看生成密钥对 查看公钥内容
cat ~/.ssh/id_rsa.pub
1
查看密钥 将公钥内容(全部)复制并粘贴(注意:公钥内容以ssh-rsa开头)
[root@i-root .ssh]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDiRO4DgUcGDuiLLW03VwDki/1vLLOCL6e5RltsxeqE041JPRO0PWNW3dcUFWHDrdJdXvoIu3C0S1234efwerwsdflndjabACcabYy7lmEeH3TRocwWS9JNpDhQFJ/rdgg4TK6v9nBWw78RrdBFdbi4QOjtUF26wDfvApmYsdd+lW/xwewe/jgy9riQHI8+2l/AGzMvTNFI8FABzpHrJhOwOQnEom53/aZlN5rWAmXNDqRnNgvLhwy2o2kxeEkYlbpLm9su+0xKL9MuGX3s41zI+uJR5+etweglkhalLHKJHO345SDFWER xxxx@qq.com
1
2
登录如下地址
https://gitee.com/profile/sshkeys
添加到gitee 添加公钥完成后进行测试公钥(测试SSH链接)
回到电脑界面输入 ssh -T git@gitee.com
[root@i-root .ssh]# ssh -T git@gitee.com
Warning: Permanently added ‘gitee.com,212.23.32.123‘ (ECDSA) to the list of known hosts.
Hi liuyulong! You‘ve successfully authenticated, but GITEE.COM does not provide shell access.
当终端提示welcome to Gitee.com,yourname!表示链接成功 至此以后只要拷贝ssh链接地址,然后利用git指令即可进行相关操作!