添加码云的ssh公钥需要先获取本地sshkey
sshkey在当前用户目录下 .ssh/id_rsa.pub
可以直接使用下面的命令查看 cat ~/.ssh/id_rsa.pub
[dylan@localhost .ssh]$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCflJVPEzM+M5inAlgGzWSqAIV+mtGJ+KMlf
tsC6uTGoxXrQ3xqRMZN9VnO9DFGN7tjJMxSyAFN9myf6j7i6asJ5nJbXcZUVRiiWxUhWY3eQz
hrD08paCaHcon6v+WZqFXvAMM3Sg7HzcjYgN4Ldd3XIps3HP8CjgKDMdQb3LRnLqec2QYVe0v
mSAn4UNT3E+UjsUyQhJY/n9SMNRIxutbYu91w9UrRlC1QT3r+k5t5sqSFEHtCgx57UWozfzzg
Sz01u/+IrUvQ3eWqhZ11uwFJQ4mCnpug1V59fDQ1iYo5mXi6735Q+i7EHL3CR3/q8K/Lpj4Rx
CX0mBnJKIYsafKz dylan_wang_love@163.com
如果找不到id_rea.pub文件需要先生成sshkey
使用 ssh-keygen -t rsa -C ”
XXX@XXX.com
” 命令引号内使用自己的邮箱
命令执行的过程中需要点击三次回车,就是代码中 Enter 的位置
之后再查看一下文件目录就能看到.ssh/id_rsa.pub的文件了
[dylan@localhost .ssh]$ ssh-keygen -t rsa -C "dylan_wang_love@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/dylan/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/dylan/.ssh/id_rsa.
Your public key has been saved in /home/dylan/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:HXPjRJpnXBi4+Sb/tryGu9QB9fDNv3ygik4y3TN4n1E dylan_wang_love@163.com
The key's randomart image is:
+---[RSA 2048]----+
| .oo+ |
| .=.o =.|
| =oO =|
| .oO o .|
| S ... E .|
| . o. o+.o.|
| o + =++..o.|
| + o *o+o .|
| .o . =*=o |
+----[SHA256]-----+
[dylan@localhost .ssh]$ ls
id_rsa id_rsa.pub known_hosts
然后登陆码云首页点击头像右上的编辑按钮
进去之后在左侧菜单中选择ssh密钥,将最开始得到的sshkey复制到右边下方的大文本框内
标题可以不用填写,我是输入完公钥标题就自动添上了
注意前面的ssh-rsa 这个也要复制的
最后一步是激活公钥(网上说的是添加可信用列表)
使用命令 ssh -T
git@gitee.com
[dylan@localhost .ssh]$ ssh -T git@gitee.com
Hi 放了那禽兽! You've successfully authenticated, but GITEE.COM
does not provide shell access.
这些都是我在网上找东西边学边做做出来的,方法跟其他的都一致
转载于:https://my.oschina.net/flnqs/blog/2032376