-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsmith_connect
executable file
·34 lines (27 loc) · 1.04 KB
/
smith_connect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
# Author: Kurt Irvin Rojas
# https://github.com/kimrojas/smith_utils
"""
SMITH CONNECT
A "smart" connection login utility for smith.
This will automatically decide if you will connect
using a local or global ssh protocol with local as priority.
No more manual ssh typing.
"""
import sys, os, subprocess
sys.dont_write_bytecode = True
from smith_user_parse import user
import smith_check
from smith_output import blue, green, warning, fail, bold, underline
print(green(f"CONNECTING TO SMITH SERVER ({user['smith_username']})"))
print(green(f"{'-'*53}"))
method = smith_check.check()
if method == 'UseLocal': bashCommand = f"ssh -Y {user['smith_username']}@{user['smith_ip']}"
if method == 'UseGlobal': bashCommand = f"ssh -Y {user['smith_username']}@localhost -p {user['smith_univ_port']}"
output = subprocess.run(bashCommand, shell=True)
if output.returncode != 0:
print(fail(f"{'-'*53}"))
print(green("CONNECTION FAILURE"))
sys.exit()
print(green(f"{'-'*53}"))
print(green("CONNECTION TERMINATED"))