I am not able to copy files through SCP command from my local machine where Jenkins is running to remote ubantu server. I have created a simple Build Step with Execute Windows batch command. Below is the command
scp -i “D:\temp\dev.ssh.keys” D:\Temp\index.html firstname.lastname@example.org:/var/www/html/output/
I have configured SSH key on remote server correctly and if I run the above command separately on Windows Command Prompt it is copying the file successfully where as on Jenkins it is not showing any error just keep on running.
Tomcat - 9.0.73
Jenkins - 2.387.2 (deployes as war file on tomcat server)
Java - OpenJDK17U-jre_x64_windows_hotspot_17.0.6_10
Are you running the command as the same user on the command line as Jenkins is running as? My guess would be the host key is not accepted on the agent machine.
Hi Alex, Thaks for the reply.
My windows user id, Jenkins user id and remote server (ubantu) user id all three are same only.
There should not be any issue with host key as the same batch file if I run through command prompt is working fine.
The problem is like it is not giving any error just keep on running. So I am not able to figure it out what is the root cause.
Does the command require a password?
When i run through command prompt it does not require a password as SSH keys are setup correctly.
When I run through Jenkins build it is not asking any password but keep on running not giving even any error.
Please see the attached screenshot.
that sounds like different users. One user might have different envionment or home directories set.
I would recommend running a tool to export your environmental variables (set in windows, export in linux) in both your job and your “command prompt” to see whats different. I would bet its different users and thus different home directories, and thus different places for ssh keys to be installed.
Thank @halkeye , i’ve changed user run Jenkins from SYSTEM LOCAL to .\Administrator and SCP ok. Thank you so much again!