Script that runs several ssh sessions consecutively

Backlog

Script that runs several ssh sessions consecutively

avatar

My company uses a bastion SSH server to connect to many of our ssh clients. I'm trying to create a script that could run once logged into bastion that will ssh to a client, run a couple commands, exit and then ssh to the next client and repeat.
This seams too much for post login commands, and I've tried to create a script/macro and excecute it, but it fails on the passwords for each ssh client. I've entered them in plain text in the macro, but when run it does not appear to accept the entry on bastion.

Any suggestions on running several ssh connections consecutively and automatically from within one bastion connection?

All Comments (1)

avatar

Hello,

Thank you for contacting us on this matter!

For your use case, I recommend configuring your SSH entries to open with a playlist. Once the playlist runs and all sessions open, go to the Actions tab and enable "Broadcast all". This ensures that everything you type in the first session is automatically sent to all the others.

Next, you can run your script using the "Execute command from palette" feature. To add one, click the "+" icon to add your script, then search for and execute it. The command will then run across all your sessions simultaneously.

Here's the exact steps for the configuration:

  • Create a Playlist for your SSH entries

https://docs.devolutions.net/rdm/commands/edit/play-list/play-list-actions/

  • Run the playlist to open all your SSH entries.


  • Select the Actions tab and click "Broadcast all"

https://docs.devolutions.net/rdm/kb/how-to-articles/broadcast-actions-in-ssh-sessions/

  • Under the first SSH session, in the icons at the top, select the last option to the far right, "Execute command from palette."

https://docs.devolutions.net/rdm/kb/how-to-articles/command-palette-ssh/#access-terminal-commands-via-the-command-palette

  • After, in the prompt that will appear, click on the "+" and add your script under the "Run" field and press Add. (Not the path to the executable, but the whole script)


  • Then, in the "Execute command from palette search bar," search for the name given to the previously configured command and Double-click on it to execute it.


2025-09-23_11-18-57.png

Please let me know if this approach fits your needs. If you have any other questions, please let us know.

Best regards,

Maxim Robert

2025-09-23_11-18-57.png