Unable to execute script over SSH from Jenkins

Andy001

New Member
Joined
Dec 12, 2018
Messages
3
Reaction score
0
Credits
0
Hello,

I am trying to excecute script on remote Debian machine from Jenkins. I have working SSH Connection from Jenkins to Linux machine but cannot excecute script. I am using Publish over SSH plugin in Jenkins and that script command is placed in "Exec command". I have tried various paths without success. I get following error lines in Jenkins log: "SSH: EXEC: STDOUT/STDERR from command [./test] ..." and "fatal: unrecognized command". That [./test] is the script on remote machine that just prints out test message at this point. I am still wondering about that unrecognized command part. Is that referring to SSH command? Script is executable.

I can even excecute that script from my windows machine with ssh <user@remote_machine> <script>. I am using another user for this test but ssh connection is working from Jenkins to Linux machine when i run test from Jenkins configuration page.

I have a another remote SSH server setup in that same Jenkins configuration that is working just fine and excecutes its script on another remote Linux machine. The configurations between two SSH servers are same in Jenkins end. Different ssh keys of course and so on.

Could there be some Linux configuration detail on my another Linux machine that prevents ssh script excecution from Jenkins machine? Something to do with SSH configuration or permissions? Maybe something wrong with environment variables?

I am bit of a beginner with Linux systems and could not find the answer to this problem.

Appreciate any help.

Thanks!
 
Last edited:


If you tail the logs on the debian machine, can you see the jenkins server making the connection? If so, can you tell if it's failing authentication or some other error?
 
Looking around a little more.. you may want to check these things as well..

- if you're using sudo and running commands remotely, add the !requiretty to the sudoers for that user like:
Defaults:username !requiretty

- They system may be unable to find the commands you're specifying in your script.. check to see if you have the full paths to the commands like /bin/cat instead of cat..
 
Hi,

thanks for your reply. Below is snippet from auth.log and those lines are coming from Jenkins(xxx is user name I am using in Jenkins):

.....
systemd-logind[347]: New session 6902 of user xxx.
sshd[7747]: pam_unix(sshd:session): session closed for user xxx
systemd-logind[347]: Removed session 6902.
systemd: pam_unix(systemd-user:session): session closed for user xxx
.......

That's all it logs out for this session. But is there something wrong here after all? Should there be line something like: "pam_unix(sshd:session). session opened for user xxx" ? What about that pluggable authentication module (PAM) configuration? Anyway SSH test result from Jenkins configuration page is Success. There are another log files in addition to auth.log in /etc/log directory but I guess auth.log is the one that is relevant in this case?

I am not using sudo for running script and the script itself is (just for testing purposes)

#!/bin/sh
/bin/echo 'Hello'

Thanks!
 
Auth.log has following lines also:

sshd[12447]: Accepted publickey for xxx from xxx.xx.x.xx port xxxx ssh2: RSA aa:...
sshd[12447]: pam_unix(sshd:session): session opened for user xxx by (uid=0)

Jenkins console output is following:

SSH: Connecting with configuration [XXX server] ...
SSH: Creating session: username [xxx], hostname [xxx.xxx.xxx, port [22]
SSH: Connecting session ...
SSH: Connected
SSH: Opening exec channel ...
SSH: EXEC: channel open
SSH: EXEC: STDOUT/STDERR from command [./jenkinsScript/test.sh] ...
SSH: EXEC: connected
fatal: unrecognized command './jenkinsScript/test.sh'
SSH: EXEC: completed after 204 ms

Can you deny/allow specific user for script excecution over SSH from Debian?

File: /etc/group ?
 
Last edited:

Members online


Top