-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsrsh.sh
44 lines (33 loc) · 1.11 KB
/
srsh.sh
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
35
36
37
38
39
40
41
42
43
44
#!/bin/bash -e
#ssh://port31%3Bpassword%[email protected]/
#REQUIREMENTS:
#Python 3.x
#sshpass
function call_python
{
python - << END
import sys
def url_host(str_input):
int_arg_num = 1
str_uname = str_input.lstrip("ssh://")
str_uname = str_uname.split(";")[0]
str_uname = str_uname.split("3B")[0]
str_uname = str_uname.replace("%","")
str_password = str_input.split("%3Bpassword%3D")[1]
str_password = str_password.split("@")[0]
str_server = str_input.split("@")[1].strip("/")
str_locale = str_uname+"@"+str_server
str_print = str_uname+"@"+str_server
str_result = str_print+","+str_password
return str_result
if __name__ == "__main__":
print(url_host("$1"))
END
}
echo "URL Collected"
str_url_pass=$(call_python "$1") || (clear && echo " " && echo "Please Give a ssh URL as first argument encapsulated with quotes" && exit 1);
IFS=', ' read -ra arr_result_bash <<<$str_url_pass;
echo "Host = "${arr_result_bash[0]};
echo "Password = "${arr_result_bash[1]};
sshpass -p ${arr_result_bash[1]} ssh -o StrictHostKeyChecking=no ${arr_result_bash[0]}
read emp