(Error while running a command with SSH) command-line: line 0: Bad configuration option

Viewed 6610

Error Msg:

command-line: line 0: Bad configuration option:

sh '''ssh -i ${rundeck_rsa_key} -o StrictHostKeyChecking=no -o centos@xxxx.net "sudo su -c "sh ./home/centos/releases/xx.sh" rundeck"'''

Broken Down command (I just made the above command for your convenience)

sh '''ssh -i ${rundeck_rsa_key} -o StrictHostKeyChecking=no 
      -o centos@xxxx.net "sudo su -c "sh ./home/centos/releases/xx.sh" servc"'''

I'm trying to

  1. ssh into the server
  2. change user to "servc"
  3. execute xx.sh shell

I think there is a syntax error on "sudo su -c "sh ./home/centos/releases/xx.sh" servc"

Do you have any clue?? :D

1 Answers

You can't nest a double quoted string inside another without escaping the inner ones.

Try this:

sh '''ssh -i ${rundeck_rsa_key} -o StrictHostKeyChecking=no -o centos@xxxx.net "sudo su -c \"sh ./home/centos/releases/xx.sh\" rundeck"'''
Related