SSH Login with Password in URL

陌路散爱 提交于 2019-12-21 17:19:06

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/16267644/ssh-login-with-password-in-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!