0

I'm having issues deploying my git files to a ubuntu server from jenkins using ssh, which is installed on another ubuntu server.

I've tried to follow various guides such as how to setup ssh keys for jenkins to publish via ssh and https://www.youtube.com/watch?v=UPSpLDnuJC0, but without any luck. For the Stackoverflow guide i get the error jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [webapp]. Message [java.net.ConnectException: Connection refused (Connection refused)]] and for the youtube guide i get: Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,password). Build step 'Execute shell' marked build as failure.

I've done ssh-keygen on the jenkins server as the jenkins user (whoami=jenkins) in the /var/lib/jenkins/.ssh/id_rsa directory, copied the contents of the id_rsa.pub file to the webapp server authorized_keys file etc. Everything done exactly as in the guides, but somehow i keep getting denied.

Ideas and help is most welcome.

  • With some tinkering i can also get the error message `jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [webapp server ]. Message [Auth fail]]` from the stackoverflow guide. Not sure which one is closer to the end goal though. – Kasper Lederballe Sørensen Sep 25 '18 at 09:54
  • Is the user "jenkins" defined on the webapp server? – triplem Sep 25 '18 at 10:30
  • No. I login with username@webappserver. Does the username have to be jenkins? – Kasper Lederballe Sørensen Sep 25 '18 at 10:49
  • The login-username should be jenkins or you need to define in jenkins the name of the user. – triplem Sep 25 '18 at 10:54

1 Answers1

0

The username on the webappserver does have to match the used username to login from jenkins, otherwise SSH does not know, which username to use and you do get the already defined error.

You do have to possibility to define the jenkins user on your webappserver or you can use a different user and define this user then in the jenkins credentials.

triplem
  • 1,324
  • 13
  • 26