换了新电脑,要克隆上传代码,直接告诉我被拒绝
。
Cloning into 'app'...
The authenticity of host '[bitbucket.bj.ssdn.accounts]:9887([10.10.2.1]:9887)' can't be established.
RSA key fingerprint is ...................fsdfdo.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[bitbucket.bjg.ssdn.accounts.intern]:7999,[10.10.2.1]:9887' (RSA) to the list of known hosts.
git@bitbucket.bj.ssdn.accounts: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Git 生成 SSH Key:
在C:\Users/你的用户名目录下,
也可以命令行查看是否已经有了ssh密钥:
cd ~/.ssh
然后进行生成,记得邮箱写正确:
ssh-keygen -t rsa -C “feifei@zoe.com”
我的执行完,点3次回车,不设置密码
$ ssh-keygen -t rsa -C “feifei@zoe.com”
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/houhongf/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/houhongf/.ssh/id_rsa.
Your public key has been saved in /c/Users/houhongf/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:8AiRjN0xPTnmJebRHKC6ZNIj2mTD/6SBiYgM4UvDg5E “feifei@zoe.com”
The key's randomart image is:
+---[RSA 3072]----+
| +.ooo.=.. |
| .. +..oX + |
|E . o= * |
|++ . o +o |
|o*B * . S |
|**+X o |
|=o+ + . |
| = |
| . . |
+----[SHA256]-----+
.ssh文件夹下,会有新文件
我现在使用的是bitbucket.需要把id_rsa.pub公钥,打开复制,然后到git 库,添加key
点击bitbucket中,我的头像,选择Account settings,找到SSH keys,点击Add key,进行添加
把上文中生成的.ssh文件夹下的id_rsa.pub复制下,添加到下图中,点击add即可
就可以在新电脑中正常操作git库了。
百度了下原因,Git是分布式的代码管理工具,远程的代码管理是基于SSH的,所以要使用远程的Git则需要SSH的配置。