The idea is to connect to a remote device bluecoat proxy over SSH, let the script do the authentication and execute the commands over in another script, create file with name date & time and save the output to local directory from where the script is running, without the need of upload this script to a remote server.

I have prepared the script as below: HC.sh

Date=`date +"%b-%d-%y_%I-%M"`
ssh user@$1 'bash -s' < Proxy.sh >HC_$1_$Date.txt

I have another script with set of commands : Proxy.sh

echo "Please print me to test1"

echo "  "
echo "********************************** Date***************************************"
show version
echo "  "
echo "********************************** Status***************************************"
show date

Both the file have permission set as : -rwxrwxrwx

Executing sh Proxy.sh 192.x.x.x (192.x.x.x device IP) from "Bash on Ubunto on Windows 10" I could prompt for the device, post supplying password, it just not providing anything, immediately go to next line and a file name with 0KB size creating. Basically the Proxy.sh is not running.

  • how to make that works ? I have the same requirement for checkpoint firewall. I am trying to see if this similar set up can be possible for checkpoint firewall as well. I have this script basically to run health check of the device. – Nic Dec 25 '18 at 9:55
  • For general health checks I would use SNMP instead – Rui F Ribeiro Dec 25 '18 at 14:03
  • 1
    @RuiFRibeiro the command as presented (ssh remote 'bash -s' < file) will do the redirection locally; the < is outside the ' quotes so is part of the command line shell. – Stephen Harris Dec 25 '18 at 15:29
  • @Nic what happens if you do echo echo hello | ssh user@remotehost ? – Stephen Harris Dec 25 '18 at 15:30
  • Hi Stephen, Apologies for the late response. I modified as you said and still an empty file created. – Nic Jan 6 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.