Jump to content

Long story short, my school runs a couple of message boards from Pi2s (raspian). The tech club maintains the boards from glitches, network outages, page freezes, etc. Its become obvious that the club won't be around next year, so we're trying to set the teachers who run the messages up to correct the boards themselves.

We use ssh, and I'm working on some scripts with plink/putty to run the various commands when clicked on.  [she struggled to replace text in html for the message boards, so i dont want to teach her bash]

But, in the mean time I thought I'd ask if anyone knows of a program that I can program to run these commands from windows since that would be easier and neater. I know/use SSH Button on android and love it, is there a windows alternative? 

Thanks

                     .
                   _/ V\
                  / /  /
                <<    |
                ,/    ]
              ,/      ]
            ,/        |
           /    \  \ /
          /      | | |
    ______|   __/_/| |
   /_______\______}\__}  

Spoiler

[I5-12600k | 32gb DDR5 6000 | RTX5070 | 2x1tb M.2]

 

[Ryzen 5 1600 | 16gb DDR4 3200 | GTX1030 | 4x 8tb HDD] 

 

Link to comment
https://linustechtips.com/topic/583414-repetitive-ssh/
Share on other sites

Link to post
Share on other sites

You are aware that you can run commands on a remote machine through the ssh command line itself, right?

 

For example:

 

ssh root@192.168.0.20 'rm /tmp/hosts ; mv /tmp/hosts-mod /tmp/hosts ; killall -SIGHUP dnsmasq'

 

deletes /tmp/hosts, copies /tmp/hosts-mod onto /tmp/hosts, and then proceeds to send SIGHUP to all dnsmasq processes running on 192.168.0.20 as root.

 

I don't know if Putty supports this syntax, or if you'd have to install openssh on the Windows clients. 

 

My gut feeling -- no non-technical teacher is gonna want to learn unix just to maintain this.   Your efforts are interesting, but without active ownership of a system, doomed to fail.
 

 

 

Link to comment
https://linustechtips.com/topic/583414-repetitive-ssh/#findComment-7612419
Share on other sites

Link to post
Share on other sites

5 minutes ago, Mark77 said:

You are aware that you can run commands on a remote machine through the ssh command line itself, right?

 

For example:

 

ssh root@192.168.0.20 'rm /tmp/hosts ; mv /tmp/hosts-mod /tmp/hosts ; killall -SIGHUP dnsmasq'

 

deletes /tmp/hosts, copies /tmp/hosts-mod onto /tmp/hosts, and then proceeds to send SIGHUP to all dnsmasq processes running on 192.168.0.20 as root.

 

I don't know if Putty supports this syntax, or if you'd have to install openssh on the Windows clients. 

 

My gut feeling -- no non-technical teacher is gonna want to learn unix just to maintain this.   Your efforts are interesting, but without active ownership of a system, doomed to fail.
 

 

 

Perhaps I should have been more clear, we use ssh on various computers throughout the school with PuTTY since they are windows(to my knowledge windows doesn't negatively have ssh) to remotely control the message boards. 

The teachers won't be learning bash, so I am trying to write some scripts that run the commands that we use automatically with a simple click, it basically pipes the commands that we save as a .txt through putty to the remote message boards. 

We don't have entire admin permission on the computers but 1)we have enough to do this and 2)our club overseer is the district IT admin so we can get admin rights when needed. 

                     .
                   _/ V\
                  / /  /
                <<    |
                ,/    ]
              ,/      ]
            ,/        |
           /    \  \ /
          /      | | |
    ______|   __/_/| |
   /_______\______}\__}  

Spoiler

[I5-12600k | 32gb DDR5 6000 | RTX5070 | 2x1tb M.2]

 

[Ryzen 5 1600 | 16gb DDR4 3200 | GTX1030 | 4x 8tb HDD] 

 

Link to comment
https://linustechtips.com/topic/583414-repetitive-ssh/#findComment-7612465
Share on other sites

Link to post
Share on other sites

Okay, so what's the technical question?  Basically this is how I read it:

 

"I want a program that runs under MS-Windows that will execute commands remotely on a unix-running computer with a ssh daemon".

 

My answer:

 

"install openssh on Windows, and use the Windows command line to initiate a ssh connection to a machine remotely, passing commands".

 

https://github.com/PowerShell/Win32-OpenSSH/releases/

Link to comment
https://linustechtips.com/topic/583414-repetitive-ssh/#findComment-7612487
Share on other sites

Link to post
Share on other sites

1 minute ago, Mark77 said:

Okay, so what's the technical question?  Basically this is how I read it:

 

"I want a program that runs under MS-Windows that will execute commands remotely on a unix-running computer with a ssh daemon".

 

My answer:

 

"install openssh on Windows, and use the Windows command line to initiate a ssh connection to a machine remotely, passing commands".

 

https://github.com/PowerShell/Win32-OpenSSH/releases/

I more than less bolded my question, I'm looking for a program that can easily save and re-run the commands with a simple click.

If you haven't used the android app, you set up the command, host, credentials, and name the button; then just press said button to run the command. I'm looking for a windows alternative since these various scripts and text files are messy and will take awhile to set up on other computers. 

I didn't think about a windows daemon for ssh, that will speed things up, thanks.

                     .
                   _/ V\
                  / /  /
                <<    |
                ,/    ]
              ,/      ]
            ,/        |
           /    \  \ /
          /      | | |
    ______|   __/_/| |
   /_______\______}\__}  

Spoiler

[I5-12600k | 32gb DDR5 6000 | RTX5070 | 2x1tb M.2]

 

[Ryzen 5 1600 | 16gb DDR4 3200 | GTX1030 | 4x 8tb HDD] 

 

Link to comment
https://linustechtips.com/topic/583414-repetitive-ssh/#findComment-7612506
Share on other sites

Link to post
Share on other sites

21 hours ago, RedWulf said:

I'm looking for a program that can easily save and re-run the commands with a simple click.

If you're already using it, PuTTY can do that for you. Navigate to the Connection > SSH section of the category tree and type the remote command, then click back on Session at the top of the tree without clicking the Open button. Save it as a Saved Session from that section. You can then create a shortcut to putty.exe and pass the session name as an argument and it'll run the command.

Capture.PNG

Link to comment
https://linustechtips.com/topic/583414-repetitive-ssh/#findComment-7616728
Share on other sites

Link to post
Share on other sites

Putty can do this with the -m option, which executes commands from a txt file. Here is an example:

 

SCRIPT:

@ echo off
//PART 1
SET /P url=[Please enter the twitch.tv username or a shortcut 1:TotalBiscuit 2:ESLCSGO]
SET /P quality=[Please enter the quality]
if %url% == 1 GOTO TB
if %url% == 2 GOTO ESL
else (
// PART 2
echo livestreamer twitch.tv/%url% %quality% -np "omxplayer -o hdmi" > C:\Users\Tobias\Twitch\commands.txt
GOTO END
)
:TB
echo livestreamer twitch.tv/totalbiscuit %quality% -np "omxplayer -o hdmi" > C:\Users\Tobias\Twitch\commands.txt
GOTO END
:ESL
echo livestreamer twitch.tv/esl_csgo %quality% -np "omxplayer -o hdmi" > C:\Users\Tobias\Twitch\commands.txt
GOTO END
//PART 3
:END
cd C:\Program Files (x86)\PuTTY
putty.exe -ssh pi@192.168.2.22 -pw 123456 -m C:\Users\Tobias\Twitch\commands.txt
exit

EXAMPLE FILE GENERATED BY SCRIPT:

livestreamer twitch.tv/esl_csgo best -np "omxplayer -o hdmi" 

 

I wrote this script to play twitch streams on a raspberry pi in the LAN. I'm aware that it isn't 100% syntactically correct. Here's how it works:

PART 1 is the text interface, this might be useful, so your teachers have to just execute 1 script and then choose what they want to do.

PART 2 is where it gets interesting. Here we generate the commands in the text file, depending on what option was selected in Part 1. The existing commands in the text file get overwritten. The commands file should be a location, where it doesn't get deleted by accident.

PART 3 is the important bit. We run Putty and tell it to execute the commands in the file on the Pi. 

WARNING: If you use the -pw option to login without the password, it will be visible by opening the batch script in editor! 

 

Hope this helps

Molex to SATA, lose all your data

 

 

Link to comment
https://linustechtips.com/topic/583414-repetitive-ssh/#findComment-7629120
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×