Start a new terminal while running commands on remote server through ssh

#1

I want to ssh to another server and run some scripts there. This is supposed to be a portion of another script that runs on local server. Is it possible to start a new terminal session to run the portion where I ssh to the remote server?

0 Likes

#2

Welcome @Sourav_Rajeev

Yes, but your question is not very clear. One can run it as follows:

ssh user@server
/path/to/script

OR

ssh user@server /path/to/script

Is that what you want? If /path/to/script is on local system, you need to add ssh command as follows in script it self:

#!/bin/bash
echo "Starting local script"
date
echo "Login and running command on remote box"
ssh user@remote-box << 'EOF'

command1-to-run-on-remote-box
command2-to-run-on-remote-box

EOF

HTH

0 Likes

#3

I want to run

ssh user@remote-box << ‘EOF’
command1-to-run-on-remote-box
command2-to-run-on-remote-box
EOF

on a separate terminal.
Is that possible?

0 Likes

#4

What do you mean by a separate terminal? Like start a new terminal from script and run commands?

0 Likes

#5

Yes. Is that possible?

0 Likes

#6

The only way to do is as follows. The syntax to open new genome terminal

gnome-terminal -e command
gnome-terminal -e /path/to/your/ssh-script

In /path/to/your/ssh-script add your ssh command:

#!/bin/bash
ssh user@remote-box << ‘EOF’
command1-to-run-on-remote-box
command2-to-run-on-remote-box
EOF
0 Likes

#7

Okay. Thankyou so much

0 Likes

#8

I can also recommend looking into either screen tmux, that might also do what you want

0 Likes