Open several ssh terminals at once: Difference between revisions
From Sea of Fate
Jump to navigationJump to search
Created page with "==Introduction== Continuing the theme of '''Random stuff''' and more particularly of '''Code Snippets'''" |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
==Introduction== | ==Introduction== | ||
Continuing the theme of '''[[Random stuff]]''' and more particularly of '''[[Code Snippets]]''' | Continuing the theme of '''[[Random stuff]]''' and more particularly of '''[[Code Snippets]]''' and '''[[Linux Bash & Shell]]'''. This is how to open several terminals at once. | ||
==The First version== | |||
===Code=== | |||
Open a text file with the ext of .sh | |||
nano ./open_prod_terminals.sh | |||
Copy the following into the file. | |||
#!/bin/bash | |||
# | |||
# Open SSH sessions in separate terminal windows | |||
gnome-terminal --tab --title="logan" -- bash -c "ssh logan; exec bash" | |||
gnome-terminal --tab --title="fig" -- bash -c "ssh fig; exec bash" | |||
gnome-terminal --tab --title="mandarin" -- bash -c "ssh mandarin; exec bash" | |||
# | |||
exit 0 | |||
Save and exit. Next we have to make it executable. | |||
chmod +x ./open_prod_terminals.sh | |||
From now we can use ./open_prod_terminals.sh to open several terminals at once. | |||
===create an alias=== | |||
The text is a bit long and i will not want to type out the whole thing so instead we will create an alias of ./open_prod_terminals.sh. To do this open the shell configuration file | |||
nano ~/.bashrc | |||
Scroll down to the bottom and add the line | |||
alias sshp='./open_prod_terminals.sh' # alias to open production host ssh all at once | |||
Save and exit. to reload the .bashrc so the alias is available immediately we need to "source" it. | |||
source ~/.bashrc | |||
Now type sshp to open a SSH session to the Production terminals. | |||
Latest revision as of 18:59, 28 February 2025
Introduction
Continuing the theme of Random stuff and more particularly of Code Snippets and Linux Bash & Shell. This is how to open several terminals at once.
The First version
Code
Open a text file with the ext of .sh
nano ./open_prod_terminals.sh
Copy the following into the file.
#!/bin/bash # # Open SSH sessions in separate terminal windows gnome-terminal --tab --title="logan" -- bash -c "ssh logan; exec bash" gnome-terminal --tab --title="fig" -- bash -c "ssh fig; exec bash" gnome-terminal --tab --title="mandarin" -- bash -c "ssh mandarin; exec bash" # exit 0
Save and exit. Next we have to make it executable.
chmod +x ./open_prod_terminals.sh
From now we can use ./open_prod_terminals.sh to open several terminals at once.
create an alias
The text is a bit long and i will not want to type out the whole thing so instead we will create an alias of ./open_prod_terminals.sh. To do this open the shell configuration file
nano ~/.bashrc
Scroll down to the bottom and add the line
alias sshp='./open_prod_terminals.sh' # alias to open production host ssh all at once
Save and exit. to reload the .bashrc so the alias is available immediately we need to "source" it.
source ~/.bashrc
Now type sshp to open a SSH session to the Production terminals.