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 (3)

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

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
Thanks for the reply. Didn't quite meet my needs though. I should have been more specific. The commands being sent in each SSH session are different. What I need is something that will login to one session, run some commands, log out of that session and login to another session and run some different commands. Then repeat until done. OR - is there a way to send passwords via either post login commands or after open envents, so I could just login to the bastion server, and then it goes through the script of logging into each subsequent server, doing the work and moving on to the next one?

avatar

Hello Brad,

Thank you for your response!

What I would suggest is still use the steps I provided for the playlist, but instead of using the broadcasting options, configure your commands to run under Event > After open options in the properties of your SSH session.
https://docs.devolutions.net/rdm/kb/how-to-articles/entry-types-events-settings/#after-open

If you have any further questions, please don't hesitate to let us know.

Best regards,

Maxim Robert