I know this is an old thread but I thought I'd post how I was able to get the issue resolved.
The issue we were having is that the ID which Jenkins runs with doesn't have access to the directory we needed to publish our artifacts to. In order to get around this, we needed to ssh back into the server Jenkins is running on with a different ID that does have access to this directory. To get it working, we had to copy the public key generated for our Jenkins ID into the authorized_keys file in the .ssh directory for the other user we wanted to connect as. When setting up our credentials in Jenkins then, we set the username as the ID we wanted to connect with and chose to pull the private key from the Jenkins master folder (~/.ssh). After that we were able to successfully connect to the server with those credentials. It's probably fairly basic but it could be easy to mix up that step. Hopefully it helps someone! On Thursday, June 2, 2016 at 9:10:16 AM UTC-5, Sverre Moe wrote: > > I need to transfer some files to a server. > Have followed the suggestion mention in > https://issues.jenkins-ci.org/browse/JENKINS-27963 > Tried sshagent with both scp and rsync. Neither works. > > I have created a Credential for this server in Jenkins. > > Using rsync > sshagent(['repository']) { > sh "rsync -av *.rpm > [email protected]:/srv/www/htdocs/staging_rpms/" > } > > [ssh-agent] Using credentials build (repohost) > [ssh-agent] Looking for ssh-agent implementation... > [ssh-agent] Java/JNR ssh-agent > [ssh-agent] Started. > [Pipeline] { > [Pipeline] sh > [master] Running shell script > + rsync -av *.rpm [email protected]:/srv/www/htdocs/staging_rpms > Host key verification failed. > rsync: connection unexpectedly closed (0 bytes received so far) [sender] > rsync error: error in rsync protocol data stream (code 12) at io.c(641) > [sender=3.0.4] > > > Using scp > sshagent(['repository']) { > sh "scp *.rpm [email protected]:/srv/www/htdocs/staging_rpms/" > } > > [ssh-agent] Using credentials build (repohost) > [ssh-agent] Looking for ssh-agent implementation... > [ssh-agent] Java/JNR ssh-agent > [ssh-agent] Started. > [Pipeline] { > [Pipeline] sh > [master] Running shell script > + scp *.rpm [email protected]:/srv/www/htdocs/staging_rpms/ > Host key verification failed. > lost connection > > Problem because of this: > The authenticity of host 'server.company.com (192.24.17.73)' can't be > established. > ECDSA key fingerprint is 00:00:00:00:00:00:00:bc:cc:51:3f:39:f8:06:df:18 > [MD5]. > Are you sure you want to continue connecting (yes/no)? yes > Warning: Permanently added 'server.company.com' (ECDSA) to the list of > known hosts. > > Fixing this first "manually" and continued. > > Using rsync > [ssh-agent] Using credentials build (repohost) > [ssh-agent] Looking for ssh-agent implementation... > [ssh-agent] Java/JNR ssh-agent > [ssh-agent] Started. > [Pipeline] { > [Pipeline] sh > [master] Running shell script > + rsync -av *.rpm [email protected]:/srv/www/htdocs/staging_rpms/ > Permission denied (publickey,keyboard-interactive). > rsync: connection unexpectedly closed (0 bytes received so far) [sender] > rsync error: error in rsync protocol data stream (code 12) at io.c(641) > [sender=3.0.4] > > Using scp > [ssh-agent] Using credentials build (repohost) > [ssh-agent] Looking for ssh-agent implementation... > [ssh-agent] Java/JNR ssh-agent > [ssh-agent] Started. > [Pipeline] { > [Pipeline] sh > [master] Running shell script > + scp *.rpm [email protected]:/srv/www/htdocs/staging_rpms/ > Permission denied (publickey,keyboard-interactive). > lost connection > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9f906f1b-4a8d-480c-8921-8809f4bd7a89%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
