是否可以在 2 台机器上使用相同的 ssh 私钥/公钥对来访问 git 存储库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1162676/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to use the same ssh private/public key pair on 2 machines to access a git repository?
提问by Lou
I've recently setup an inhouse git repository server and have it up and running with gitosis installed as the management tool. Read only access is available via the git:// protocol and write access is available via gitosis using ssh public keys.
我最近设置了一个内部 git 存储库服务器,并在安装 gitosis 作为管理工具的情况下启动并运行它。只读访问可通过 git:// 协议获得,写访问可通过 gitosis 使用 ssh 公钥获得。
I have a developer that has been granted access to his projects with a public key that was generated on his desktop workstation.
我有一个开发人员已被授予访问他的项目的权限,该公钥是在他的桌面工作站上生成的。
He is now wanting to access that repository from his laptop using the same ssh key pair. He's copied has .ssh folder in it's entirety to his laptop and has tried to clone from the repository without success.
他现在想使用相同的 ssh 密钥对从他的笔记本电脑访问该存储库。他已将 .ssh 文件夹完整复制到他的笔记本电脑上,并尝试从存储库中克隆但没有成功。
Is this a valid thing to try?
这是一个有效的尝试吗?
Does a ssh key pair need to be generated per machine? This seems weird as it would effectively require a per machine username to be added to the gitosis configuration.
是否需要为每台机器生成 ssh 密钥对?这看起来很奇怪,因为它实际上需要将每台机器的用户名添加到 gitosis 配置中。
Any help would be appreciated.
任何帮助,将不胜感激。
采纳答案by Matt
Yes I think you can.
是的,我认为你可以。
I have something similar. Two machines, one Intel (desktop) the other one Sparc. I can log into both machines and access the same CVS server (another machine) using SSH access with the same key pair which was generated on the Intel machine.
我有类似的东西。两台机器,一台 Intel(桌面)另一台 Sparc。我可以使用在 Intel 机器上生成的相同密钥对使用 SSH 访问登录到两台机器并访问相同的 CVS 服务器(另一台机器)。
Make sure when you copy across your private key that you set both the permissions of the .ssh directory correctly (0700) and your home directory cannot be group or world writable. The id_rsa should only have user read access (0400)
确保在复制私钥时正确设置了 .ssh 目录的权限 (0700),并且您的主目录不能是组或全局可写的。id_rsa 应该只有用户读取权限 (0400)
回答by nobody
Yes, that's perfectly legitimate. ssh keys don't care where they were generated, and it's fine to have them on multiple machines at once.
是的,这是完全合法的。ssh 密钥不关心它们是在哪里生成的,并且可以同时在多台机器上使用它们。
Try giving the ssh client the "-v" or "-vv" option (for verbose output) and check the server's ssh log to debug the problem.
尝试为 ssh 客户端提供“-v”或“-vv”选项(用于详细输出)并检查服务器的 ssh 日志以调试问题。
回答by John Sundarraj
SSH key pair's are machine independent, which means you can create a SSH key pair on one machine and can deploy the same SSH key pair on multiple machines. It is valid thing to do, thats how you must do it.
SSH 密钥对是独立于机器的,这意味着您可以在一台机器上创建一个 SSH 密钥对,并且可以在多台机器上部署相同的 SSH 密钥对。这样做是有效的,这就是你必须这样做的方式。
Moreover Git uses SSH for transport, so you can clone/download the Git on both the machines having the same SSH key pair.
此外,Git 使用 SSH 进行传输,因此您可以在具有相同 SSH 密钥对的两台机器上克隆/下载 Git。