ssh script returns 255 error

前端 未结 8 812
北海茫月
北海茫月 2020-12-08 04:04

In my code I have the following to run a remote script.

ssh root@host.domain.com \"sh /home/user/backup_mysql.sh\"

For some reason it keeps

8条回答
  •  情深已故
    2020-12-08 05:01

    I was stumped by this. Once I got passed the 255 problem... I ended up with a mysterious error code 1. This is the foo to get that resolved:

     pssh -x '-tt' -h HOSTFILELIST -P "sudo yum -y install glibc"
    

    -P means write the output out as you go and is optional. But the -x '-tt' trick is what forces a psuedo tty to be allocated.

    You can get a clue what the error code 1 means this if you try:

    ssh AHOST "sudo yum -y install glibc"
    

    You may see:

    [slc@bastion-ci ~]$ ssh MYHOST "sudo yum -y install glibc"
    sudo: sorry, you must have a tty to run sudo
    [slc@bastion-ci ~]$ echo $?
    1
    

    Notice the return code for this is 1, which is what pssh is reporting to you.

    I found this -x -tt trick here. Also note that turning on verbose mode (pssh --verbose) for these cases does nothing to help you.

提交回复
热议问题