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
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.
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.
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".
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
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.
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.