我当前的命令是
git clone ssh://username@onboard.com/srv/git/repo
之后
password
...很好,效果很好。
现在我想在一行中完成此操作。类似的东西:
git clone ssh://username:password@onboard.com/srv/git/repo
但它不起作用并给我消息:
Please make sure you have the correct access rights and the repository exists.
如何在一行中克隆?
最佳答案
您应该能够使用 http
url 来克隆它:
git clone http://username:password@onboard.com/srv/git/repo.git
编辑:
如果万一您只能使用用户名密码凭据通过普通 ssh 执行此操作,请尝试使用 sshpass
,例如:
sshpass -p password git clone ssh://username@onboard.com/srv/git/repo
您可能必须为此安装 sshpass
。
请注意,这是在未正确配置 ssh key 时出现的情况;如果配置了 ssh key ,您的公钥将与目标服务器共享,您将不需要输入密码(尽管您可能必须输入密码)。
关于一次性使用用户名密码认证的Git clone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29728428/