Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins sshagent execution not working

I am trying to use sshagent options to scp/ftp files to windows and linux serers but it is not working as expected, could someone help me on this?

What should be credentials? I used encrypted userid and password value created using jenkins. What should be the command to execute to scp file to server1?

like image 910
Eldo Avatar asked Nov 15 '25 02:11

Eldo


1 Answers

You can't store a userid/password combination in an ssh agent, only a private key.

Under Jenkins -> Credentials -> System -> Global credentials in the Jenkins web interface, you can add new credentials. Go for an SSH username with private key in global scope. You can use ssh-keygen to make thew private key. Then your pipeline can do something like:

sshagent (credentials: ['58754abf756cd-6057-.....']) {
  sh 'scp file host:dir'
}

Note that the SSH agent is a plugin that needs installing.

like image 94
okapi Avatar answered Nov 17 '25 21:11

okapi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!