Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 113
  • Last Modified:

SSH Script Execution in Windows Batch

I have a HPE M330 OfficeConnect 802.11ac access point.  It needs to be rebooted periodically in order to run well.  

The easiest way to reboot the AP is to SSH in and issue the 'reboot' command.

I am able to connect via plink.exe to reach the shell and manually enter reboot, but when I try to pull the command from a text file, I get an error ": cannot open"  Ultimately, I want to create a batch file and run it as a scheduled task.  

Here's the command line:

plink -ssh admin@10.2.1.2 -pw xxxxxxx -m reboot.txt -v

reboot.txt contains reboot on a single line with a return at the end (created in notepad).

Here is the verbose output of the plink command line.  I'd appreciate any assistance.

C:\Utility>plink -ssh admin@10.2.1.2 -pw xxxxxxx -m reboot.txt -v
Looking up host "10.2.1.2"
Connecting to 10.2.1.2 port 22
Server version: SSH-2.0-dropbear_0.51
We believe remote version has SSH-2 channel request bug
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.67
Using Diffie-Hellman with standard group "group1"
Doing Diffie-Hellman key exchange with hash SHA-1
Host key fingerprint is:
ssh-rsa 1040 68:fa:ef:f2:76:35:af:5f:27:a6:db:21:b8:84:bb:b2
Initialised AES-256 CBC client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 CBC server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "admin".
Sent password
Access granted
Opening session as main channel
Opened main channel
Started a shell/command
reboot
: cannot open
Server sent command exit status 255
Disconnected: All channels closed
0
sdhonea
Asked:
sdhonea
  • 11
  • 5
  • 5
2 Solutions
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Can you try putting the reboot command on the command line? Remove -m and everything after that and replace with the contents of your text file.
0
 
sdhoneaAuthor Commented:
Result:

C:\Utility>plink -ssh admin@10.2.1.2 -pw xxxxxxx reboot
reboot: cannot open
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Very strange, works on my end to a Linux server from Windows. Can you try without the ssh and pw options?

Like this:

plink admin@10.2.1.2 reboot

It should ask for the password.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
sdhoneaAuthor Commented:
This AP won't allow the connection as telnet, has to be SSH.  

C:\Utility>plink admin@10.2.1.2 reboot
FATAL ERROR: Network error: Connection refused

If I add back the -ssh and manually enter the pw, I still get
C:\Utility>plink -ssh admin@10.2.1.2 reboot
admin@10.2.1.2's password:
reboot: cannot open
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Do you know where the reboot command is on the printer? You may have to add the path to the command line, for example:

/usr/bin/reboot
0
 
sdhoneaAuthor Commented:
The command is in /splashbin

I tried plink -ssh admin@10.2.1.2 -pw xxxxxxx /splashbin/reboot and got "Invalid command".

I tried plink -ssh admin@10.2.1.2 -pw xxxxxxx -m reboot.txt -v

and adding reboot to the text file (and also adding cd /splashbin then reboot to the text file) and I get

Started a shell/command
cd /splashbin
reboot
: cannot open
Server sent command exit status 255
Disconnected: All channels closed
0
 
sdhoneaAuthor Commented:
I tried just executing simply ls /splashbin in the command file.  Still get this error.  It accepts the command fine if I just log in and issue it.

Opening session as main channel
Opened main channel
Started a shell/command
ls /splashbin
: cannot open
Server sent command exit status 255
Disconnected: All channels closed
0
 
arnoldCommented:
On the suggested path, look where reboot is

Plink -ssh admin@10.1.2.1 -pw xxxxxxxx 'nohup /bin/reboot'
0
 
sdhoneaAuthor Commented:
reboot is in /splashbin

plink -ssh admin@10.2.1.2 -pw xxxxxxx 'nohup /splashbin/reboot'

gets this result:

'nohup /splashbin/reboot': cannot open

Thank you.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
>> I am able to connect via plink.exe to reach the shell and manually enter reboot
Can you show us the output of the reboot command that you enter manually.

What is your product ID / do you have the latest firmware version? You should not have to reboot the device periodically, I never have to reboot my wireless access point.
0
 
sdhoneaAuthor Commented:
HPE M330 OfficeConnect 802.11ac access point JL026A.  I have six of these all on the latest available firmware and they all start dropping clients after about two weeks of not being rebooted.

I agree that they shouldn't need to be rebooted...
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
And the output of the reboot ssh screen?
0
 
arnoldCommented:
Where is your DHCP server? Check the duration of the cache/arp retention.

Any loging determination what causes this situations?
0
 
sdhoneaAuthor Commented:
Do you think a longer lease would reduce the client drops?
0
 
arnoldCommented:
A shorter lease will prevent the issue where there are no more IPs to allocate because they have been allocated no the lease time has not expired.
0
 
sdhoneaAuthor Commented:
The lease is set at 24 hours.  There's no issue with insufficient addresses.  These are very small offices.

This wouldn't even be an issue except that my users are connecting to a Citrix server and the connection needs to stay alive in order to prevent an interrupted session/having to log in all over again.

I'd prefer to focus on how to automate the reboot, if possible.
0
 
arnoldCommented:
What is the consequence of running
plink -ssh user@apstation -pw xxxxxxx '/bin/nohup /full/path/to/where/reboot/is'?
plink -ssh user@apstation -pw xxxxxxx -t '/bin/nohup /full/path/to/where/reboot/is'?

try adding the -t option.
0
 
sdhoneaAuthor Commented:
nohup doesn't appear to be a supported command:
HP-WLAN-AP# find */*noh*
find: */*noh*: No such file or directory
Invalid command.

Running command without nohup:
plink -ssh admin@10.2.1.2 -pw xxxxxxx -t -v '/splashbin/reboot'

result:
Using username "admin".
Sent password
Access granted
Opening session as main channel
Opened main channel
Allocated pty (ospeed 38400bps, ispeed 38400bps)
Started a shell/command
'/splashbin/reboot': cannot open
Server sent command exit status 255
Disconnected: All channels closed
0
 
arnoldCommented:
double check that reboot is in /splashbin and is not somewhere else.


See if you have a scheduler on the system. and configure an auto-reboot once a week.....

Checking with the vendor to determine what is causing the saturation.  Do the logs indicate anything?
Is your SSID display enabled or disabled?  Any option to disable if enabled to avoid attempted attacks?
lower the Lease time to 8 hours-12hours to see if that makes a difference.

if you login onto one that is having issues and run arp -d after running arp -a
does it fix anything?

Something is causing this issue, but it is not clear what.
0
 
sdhoneaAuthor Commented:
Looks like it is an issue with the AP.  Going to reach out to Hewlett-Packard for assistance.  Thanks to all for your suggestions.
0
 
sdhoneaAuthor Commented:
None of the suggestions resolved the issue.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 11
  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now