Skip to content

Instantly share code, notes, and snippets.

@AbiruzzamanMolla
Forked from maateen/servers.py
Created December 20, 2016 22:16
Show Gist options
  • Save AbiruzzamanMolla/3d6f26c48e4a34bde862d5ba85cfd4cd to your computer and use it in GitHub Desktop.
Save AbiruzzamanMolla/3d6f26c48e4a34bde862d5ba85cfd4cd to your computer and use it in GitHub Desktop.
Hello Sysadmin, make life easier on Terminal. :)
"""
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 root@xxx.xx.xxx.xxx -p 22",
"My Client VPS": "ssh root@xxx.xx.xx.xxx -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