一次性使用用户名密码认证的Git clone

标签 git bash ssh

我当前的命令是

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/

相关文章:

vb.net - SSH.NET 的 SFTP 进度

git - Gradle bitbucket/git 发布插件

bash - shell中实时去除回车

Bash CTRL 在单词/字符串之间移动光标

bash - awk 两个文件的数字范围

amazon-web-services - Amazon EC2 ssh 操作超时

git - 按更改类型过滤 git diff

linux - git-svn 或 git-flow 命令是如何在中间没有破折号的情况下执行的

git - 如何从已经 checkout 的 pull 请求中提取更改?

linux - 我可以在我的计算机上使用 emacs 通过 ssh 将 C 代码编译到 linux 终端吗?