我的〜/ .ssh目录已删除

时间:2014-04-22 00:40:07

标签: git ssh bitbucket

我创建了一个Bitbucket / git帐户。出于某种原因,我搞砸了这些东西并没能推升回购。 匆忙中我删除了〜/ .ssh目录。

那么如何修复呢?

1 个答案:

答案 0 :(得分:0)

取决于你的.ssh目录中的内容。

通常,.ssh目录包含3种文件:

1) id_rsa / id_dsa / id*.pub - These are your private and public keys; your identity;
the key(s) that authenticate you to the remote SSH (git) server. If you lost the private
key, and don't have a backup then you are out of luck and will have to create a brand
new private/public keypair, and repeat the process you originally went through to
authorize your ssh/git client. In short, run ssh-keygen to generate new keys (today I recommend
you use 2048 bit length), and then proceed to Bitbucket to register your new public key
with the server.

2) If you also used authorized_keys, you will need to recreate that file or
find a backup. Those are only _public_ keys from other hosts that you use to login to
"this" host using key based authentication. If this is just a client machine, you likely
wont have an authorized_keys file.

3) known_hosts - The public server keys of SSH servers that you have accepted
in past sessions. It will be auto-created next time you connect to a
remote SSH server and accept a key forever. It is maintained by your SSH
clients, so don't worry about that file. You will, however, receive warnings as if
you've never connected to servers before until the file is fully repopulated.

所以重要的是(1),没有备份你的私钥是不可替换的。

<强>的BitKeeper https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git

如果链接变坏,简而言之,您使用ssh-keygen生成RSA密钥(Google ssh-keygen),然后您需要转到Bitkeeper帐户设置并添加id_rsa.pub(公钥)部分。

Github 类似: https://help.github.com/articles/generating-ssh-keys

最后,请始终在存储在物理安全位置的拇指驱动器上备份私钥文件。