-
-
Save AbiruzzamanMolla/3d6f26c48e4a34bde862d5ba85cfd4cd to your computer and use it in GitHub Desktop.
Hello Sysadmin, make life easier on Terminal. :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Documentation | |
1. At first, save the entire script as servers.py in /home/your-username/ directory. | |
Also you can simply use the below command: | |
curl "https://gist.githubusercontent.com/maateen/1582a28d62437caaf5cf9098303bab79/raw/e216b3b1ff8f1323fb79de4ae5a4c5b24a8b2c4d/servers.py" > ~/servers.py | |
2. Change info in servers = {} portion according to your need. | |
Always use Server Identity at the left side of : sign and SSH Login Command at the right side. | |
3. Open your ~/.bashrc and add a new line at the below like this: | |
alias servers="python3 ~/.servers.py" | |
4. Now play a command on your Terminal: | |
source ~/.bashrc | |
5. Now when you wanna log in any server, simply play the below command on Terminal: | |
servers | |
That's all. | |
""" | |
from os import system | |
from sys import exit | |
servers = { | |
"My Personal VPS": "ssh [email protected] -p 22", | |
"My Client VPS": "ssh [email protected] -p 22", | |
} | |
count = 1 | |
servers = servers.items() | |
for item in servers: | |
print(count, '>', item[0]) | |
count += 1 | |
servers = list(servers) | |
try: | |
choice = int(input('\nChoose your preferred server: ')) | |
print('\nConnecting to', servers[choice-1][0], '...\n') | |
system(servers[choice-1][1]) | |
except KeyboardInterrupt: | |
print('\n\nClosing forefully.\n') | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment