9

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?

1
  • did you tried using http Commented Apr 19, 2015 at 10:10

1 Answer 1

19

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).

Sign up to request clarification or add additional context in comments.

6 Comments

"not valid: is this a git repository?" I have to do this using ssh.
are you accessing this by sshkeys, or by normal username-password based ssh authentication? If it is the first, it will be possible without the password, but otherwise you can try using sshpass (Though I'm not sure of the exact command). Try something like sshpass -p password git clone ssh://[email protected]/srv/git/repo
Requires installing sshpass packet. It`s not a problem.
Be aware, that special characters in HTTP, username or password need to be encoded. Use this tool to encode those meyerweb.com/eric/tools/dencoder
@mu無 After clone with git clone http://username:[email protected]/srv/git/repo.git, how can I push it to the remote repository with my username, password?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.