Open SSH Session using MobaXterm
To open an SSH session using MobaXterm and execute commands from a file containing one command per line on a Windows system, follow the steps below:
- Ensure that the file containing the commands is in a format where each line represents a separate command.
- Open MobaXterm on your Windows system.
- Click on the "Session" menu and select "New Session."
- In the "Session" window, enter the hostname or IP address of the remote server where you want to execute the commands.
- Select the SSH protocol from the "Protocol" dropdown menu.
- Click on the "Advanced" button, and under the "Advanced SSH Settings" section, check the "X11" and "Tray Icon" options.
- Click on the "OK" button to create the session.
- In the "Terminal" window that appears, right-click and select "Paste" to paste the commands from the file.
- Press the "Enter" key to execute the first command.
- After the command execution is complete, press the "Enter" key again to execute the next command.
- Repeat step 7 until all commands in the file have been executed.
- Alternatively, use redirection to read commands from a file instead of pasting them manually. To do this, add the following syntax to the beginning of your file:
- Save the file and execute it using the following command in the MobaXterm terminal:
#!/bin/bash
sh txt