andrew
andrew

Reputation: 3151

Git clone with username password authentication in one go

My current command is

git clone ssh://[email protected]/srv/git/repo

after that

password

... fine, works good.

Now I would like do this in one line. Something like that:

git clone ssh://username:[email protected]/srv/git/repo

but it`s not working and gives me the message:

Please make sure you have the correct access rights and the repository exists.

How can I clone in a single line?

Upvotes: 9

Views: 62216

Answers (1)

Anshul Goyal
Anshul Goyal

Reputation: 77053

You should be able to use the http url instead to clone it:

git clone http://username:[email protected]/srv/git/repo.git

Edit:

If in case you can do this by normal ssh only with username-password credentials, try using sshpass like:

sshpass -p password git clone ssh://[email protected]/srv/git/repo

You might have to install sshpass for this.

Note that this is the case when the ssh keys are not correctly configured; if the ssh keys were configured, your public key would be shared with the target server and you wouldn't have needed to enter the password (you might have had to enter a passphrase though).

Upvotes: 19

Related Questions