I have a shell script that packages an application. This script, once executed, asks for SVN_USER & SVN_PASSWORD. Then exports them to the system, then runs packaging commands.

The thing is, i want to execute that script from Jenkins over ssh.

In other words, i need a way to inject my username & password in an inline command.

( i don't have the right to edit the script so i can not use $1 $2 and pass them as parameters, the script only accepts those two variables as a form input ).

i tried :

  • export SVN_USER=foo
  • export SVN_PASSWORD=bar
  • ssh -o StrictHostKeyChecking=no admin@ 'sh /base/myscript.sh appname'

--> The connectivity is fine, the script starts, asks for username and password, and fails execution since it didnt receive the information required.

Thanks for your help


I think that the only way you will be able to do this is by setting the environment inside the remote command string ex.

ssh -o StrictHostKeyChecking=no admin@ 'SVN_USER=foo SVN_PASSWORD=bar sh /base/myscript.sh appname'

Although SSH provides a SendEnv option that in principle allows you to pass environment settings from local to remote, that relies on a corresponding AllowEnv setting in the remote sshd_config file: at least in the Ubuntu, the defaults only permit locale-related environment settings i.e.

SendEnv LANG LC_*


AcceptEnv LANG LC_*
  • Thanks much, it works, but it displays the user/password, any way to hide them ? thanks again ! Mar 23 '20 at 21:21
  • @YassineBOUMAJANE the command itself shouldn't display anything - maybe they are being output by the script? if so, you could redirect the script's output to /dev/null Mar 23 '20 at 21:28
  • Jenkins shows the whole command at the time of execution, still, i consider this thread resolved because the solution you provided answers very well the question in the topic. I will open another topic concerning how to transfer secrets from jenkins inside an ssh shell script. Thanks a lot again Steeldriver !! Mar 24 '20 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.