我的~/.ssh目录已删除



我创建了一个Bitbucket/git帐户。不知什么原因,我把事情搞砸了,没能推高回购。我匆匆忙忙地删除了~/.ssh目录。

那么如何修复呢?

取决于.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+SSSH+for+Git

如果链接出现问题,简而言之,您可以使用ssh密钥生成RSA密钥(Google ssh密钥),然后您需要转到Bitkeeper帐户设置并添加id_RSA.pub(公钥)部分。

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

最后,一定要在拇指驱动器上备份私钥文件,并将其存储在物理安全的地方。

最新更新