如何避免被锁定在 GIT 存储库/SSH 之外?
我使用 ssh-keygen 创建了 ssh 密钥,然后在源代码存储库站点 assembla.com 上创建了一个存储库作为 GIT 存储库。我必须使用我的私钥(或者是我的公钥?)将文件上传到存储库,现在我可以毫无问题地克隆。
我有一个朋友尝试访问该存储库,但他无法访问,这很好,因为我没有为该存储库配置任何来宾,并希望它是私有的。
但现在我不确定如何确保我将来不会失去对自己的存储库的访问权限。我是否需要保留用户目录中 .ssh 文件夹的副本?从 mac os x 中的钥匙串工具导出钥匙串?我仍在尝试完全理解它是如何工作的,但是 SVN 不需要用户名+密码来访问存储库吗?我应该怎么做才能自信、安全地使用 GIT SSH 存储库,这样我将来就不会失去对它的访问权限?
I created ssh keys using ssh-keygen and then created a repo on a source code repo site, assembla.com as a GIT repository. I had to upload the file with my private key (or was it my public key?) to the repo and now I am able to clone no problem.
I had a friend try and access the repo and he wasn't able to, which is good because I had not configured any guests to the repo and wanted it to be private.
But now I am unsure about how to ensure that I do not lose access to my own repo in the future. Do I need to keep a copy of my .ssh folder from my user dir? Export keychains from the keychain tool in mac os x? I'm still trying to get a full understanding of how this works but doesn't SVN simply need username+pass for repo access? What should I do so I can confidently and safely use a GIT SSH repo such that I won't lose access to it in future?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该将您的私人 ssh 密钥保存在干燥、温暖、无阳光、安全的地方:您的 HDD、您的备份 HDD、您在其他城市/国家的备份位置。
由于您的密钥受到强而长的随机安全密码的保护,因此您可以“按原样”保存它,但最好保持其私密性。
You should keep your private ssh key in dry, warm, sunless, secure place: your HDD, your backup HDD, your backup place in some other city/country.
Since your key protected with strong long fat random secure password, you can save it "as is", but better to keep it private.
.ssh 文件夹中的三个文件:
known_hosts
只是您已连接到的主机的列表。其主要目的是保护您免受中间人攻击,即邪恶的人假装是您尝试连接的主机。您也可以将其包含在备份中,但这不会让您失去访问权限。id_rsa
是私钥。这是您用来识别自己身份的信息。正如其名称所示,它是私有的。就该密钥对而言,拥有它的任何人都是您。您当然应该备份它 - 但要安全!id_rsa.pub
是公钥。这就是你实际给予人们的。当您使用密钥对身份验证进行 ssh 时,服务器上的公钥和客户端的私钥的组合对您进行身份验证。也备份一下;如果没有它,您当前所做的一切都将继续工作,但您将无法将其传递到更多服务器,因此您会有点卡住。至于空密码,很多人都会这样做。这当然不是最安全的,但还有更严重的罪可犯。密码只是一层额外的保护。要识别您的身份,您必须提供私钥(您拥有的东西)和密码(您知道的东西)。在避免帐户被锁定方面,请不要忘记它,这样您就不会遇到问题。空的可以给你带来更多的便利,而且不会有忘记它的危险,但会牺牲一些安全性。
最后,大多数 git 托管并不专门使用 ssh 访问。如果您拥有可以通过其他方式进行身份验证的 assembla 帐户,那么您可能能够返回并添加或交换密钥对。
The three files in your .ssh folder:
known_hosts
is just a list of hosts you've connected to. Its primary purpose is protecting you from man-in-the-middle attacks, where someone evil pretends to be the host you try to connect to. You might as well include it in your backups, but it won't make you lose access.id_rsa
is the private key. This is what you use to identify yourself. As the name says, it's private. Anyone who has it is, as far as this keypair is concerned, you. You should certainly back it up - but safely!id_rsa.pub
is the public key. This is what you actually give people. When you ssh somewhere using keypair authentication, it's the combination of the public key on the server and the private key from your client that authenticates you. Back it up too; without it, everything you're currently doing will keep working, but you wouldn't be able to pass it out to any more servers, so you'd be kinda stuck.As for empty passphrases, well, a lot of people do that. It's certainly not the most secure, but there are worse sins to commit. The passphrase is just an extra layer of protection. To be identified as you, you have to provide the private key (something you own) and the passphrase (something you know). In terms of avoiding getting locked out of an account, well, don't forget it and you won't have problems. An empty one gives you increased convenience, and no danger of forgetting it, at the cost of some security.
Finally, most git hosting doesn't use ssh access exclusively. If you have an account with assembla that can be authenticated some other way, then you might have the ability to come back and add or swap out keypairs.