0
1
I am creating two Bash scripts on my Raspberry Pi, which is running the default Debian-based Linux distro: one to sleep my desktop computer, and one to shut it down.
The script to shutdown the computer works fine and its contents are:
sshpass -p "MYPASSWORD" ssh administrator@MYCOMPUTERNAME "shutdown /s"
My desktop is running Windows 10 and the built-in SSH server that comes with Windows 10.
When I try to run the script to sleep my computer, however, I am presented with the output:
Packet integrity error (165 bytes remaining) at ../channels.c:2401
Disconnecting: Packet integrity error.
The contents of this script are:
sshpass -p "MYPASSWORD" ssh administrator@MYCOMPUTERNAME "psshutdown /d"
'psshutdown' refers to the Windows Sysinternals utility.
Strangely, running the command psshutdown /d
from an Administrator command prompt, when sitting at my desktop, successfully sleeps my computer. It also works if I connect via SSH from the Pi without specifying a command to run once connected, i.e. sshpass -p "MYPASSWORD" ssh administrator@MYCOMPUTERNAME
, and then run the psshutdown /d
command. Running the same command as in the script directly in Bash fails with the same output as above.
Interestingly, when trying to run some other commands in the same way as in the sleep script, some work and some throw a different error. For example, sshpass -p "MYPASSWORD" ssh administrator@MYCOMPUTERNAME "whoami"
works fine and returns the correct output but sshpass -p "MYPASSWORD" ssh administrator@MYCOMPUTERNAME "date"
produces the output exec request failed on channel 0
What is causing the sleep script to fail and how can I resolve the issue to successfully run the command over SSH?
Note: I understand it is not ideal to store the SSH password in plain text in a script file but setting up key-based authentication on the built-in SSH server is a challenge for another day.
"some work and some throw a different error." - Please provide these details – Ramhound – 2017-07-15T15:48:51.037
@Ramhound Thanks for your comment. I have provided details of the error via the example of the output when running
date
– LJD200 – 2017-07-15T15:49:52.1601This could be because of your
PATH
... try specifying the full path topsshutdown
ordate
. – Attie – 2017-07-15T16:03:45.1071@Attie Thanks for your comment. I have also already tried specifying the full path to
psshutdown
. I should have mentioned that in the question - I'll edit it now. – LJD200 – 2017-07-15T16:05:22.7931One other thought re
psshutdown
... if it's working, then it's very possible that the windows network stack is being suspended before the SSH session completes - hence thePacket integrity error
... – Attie – 2017-07-15T16:06:54.2301@Attie Although I'm certain that I'd already tried specifying the full path to
psshutdown
, when doing so again, the script ran successfully and my PC slept! Thanks for your help. That was a very strange issue. – LJD200 – 2017-07-15T16:11:40.773