Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH Login with Password in URL

I have Jenkins cloning the Git repository at

ssh://user@ip/repo/

and it all works fine, but I need to login with a password, which Jenkins doesn't support. Is there a way to login with the password in the URL? Security is not an issue for me. It should end up being, and I thought it was this at first:

ssh://user:pass@ip/repo/

but it doesn't work. Thanks!

Update #1: The git repo is on the same server.

like image 553
Ryan Avatar asked Apr 28 '13 20:04

Ryan


2 Answers

There are two reason why SSH ask you for a password:

  • the public key isn't found on the server, meaning ssh defaults to the account used for the ssh session, asking for its password
  • the public key is found, but the private key is password-protected.

The first case means ssh isn't working properly: you should never have to enter the password of the account you are using for ssh.
The idea is to be able to authenticate someone even though all ssh connections will use one unique account. Entering the password of that unique account defeat the purpose.

The second case should be easy to solve, by running ssh-agent and ssh-add.
That would allow you to not enter the password (more than once, when adding the key to the agent).

like image 157
VonC Avatar answered Oct 20 '22 00:10

VonC


Someone could correct me, I don't think this is possible since the password prompt is actually from the SSH server, and not from the SSH application. Looking at my local SSH help page, and there's no way to pass a password into SSH from the command line. This also has some serious security risk with it since the password would be available in plain text.

With that, your best (and more secure) bet would be to do a public/private key pair which wouldn't need a password to setup. Getting this setup with Jenkins and Git can be a little challenging depending on your environment, but it is completely worth it in the end.

like image 26
Steven V Avatar answered Oct 19 '22 22:10

Steven V