ssh script returns 255 error

前端 未结 8 768
北海茫月
北海茫月 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 04:44

    It can very much be an ssh-agent issue. Check whether there is an ssh-agent PID currently running with eval "$(ssh-agent -s)"

    Check whether your identity is added with ssh-add -l and if not, add it with ssh-add <pathToYourRSAKey>.

    Then try again your ssh command (or any other command that spawns ssh daemons, like autossh for example) that returned 255.

    0 讨论(0)
  • 2020-12-08 04:50

    If there's a problem with authentication or connection, such as not being able to read a password from the terminal, ssh will exit with 255 without being able to run your actual script. Verify to make sure you can run 'true' instead, to see if the ssh connection is established successfully.

    0 讨论(0)
  • 2020-12-08 04:54

    This error will also occur when using pdsh to hosts which are not contained in your "known_hosts" file.

    I was able to correct this by SSH'ing into each host manually and accepting the question "Do you want to add this to known hosts".

    0 讨论(0)
  • 2020-12-08 04:56

    If above didn't help: check if locale is valid on client and server:
    https://www.linuxbabe.com/linux-server/fix-ssh-locale-environment-variable-error
    How do not pass locale through ssh

    0 讨论(0)
  • 2020-12-08 04:59

    SSH Very critical issue on Production. SSH-debug1: Exit status 255

    I was working with Live Server and lots stuff stuck. I try many things to fix but exact issue of 255 don't figure out.

    Even I had resolved issue 100%

    Replace my sshd_config file from similar other my debian server

    root@snippetbucket.com:~# cp sshd_config sshd_config.snippetbucket.com.bkp #keep my backup file

    root@snippetbucket.com:~# echo "" > sshd_config

    root@snippetbucket.com:~# nano sshd_config #replaced all content with other exact same server

    root@snippetbucket.com:~# sudo service ssh restart #normally restart server

    That's 100% resolve my issue immediate.

    #SnippetBucket-Tip: Always take backup of ssh related files, which help on quick restoration.

    Note: After apply given changes you need to exit rescue mode and reboot your vps / dedicated server normally, than your ssh connection works.

    During rescue mode ssh don't allow user to login as normally. only rescue ssh related login and password works.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题