-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaccess.sh
More file actions
159 lines (135 loc) · 3.57 KB
/
Copy pathaccess.sh
File metadata and controls
159 lines (135 loc) · 3.57 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
#var for colors
RED='\033[0;31m'
MANGENTA='\e[95m'
GREEN='\e[92m'
CIAN='\e[96m'
YELLOW='\e[93m'
NC='\033[0m' # No Color
clear #clear output
#MAIN MENU
menu() {
clear
#normal menu
echo -e "${RED}Made By MKvO"
echo -e " ${CIAN} _______________________________ "
echo -e " / \ "
echo -e " ${CIAN}|${GREEN} % % % % %%%%%% ${CIAN} |${NC}"
echo -e " ${CIAN}|${GREEN} %% %% % % % % ${CIAN} |${NC}"
echo -e " ${CIAN}|${GREEN} % % % % % % % % % % ${CIAN} |${NC}"
echo -e " ${CIAN}|${GREEN} % % % %%% % % % % ${CIAN} |${NC}"
echo -e " ${CIAN}|${GREEN} % % % % % % % % ${CIAN} |${NC}"
echo -e " ${CIAN}|${GREEN} % % % % % % % % ${CIAN} |${NC}"
echo -e " ${CIAN}|${GREEN} % % % % %% %%%%%% ${CIAN} |${NC}"
echo -e " ${CIAN}\_______________________________/${NC}"
echo -e " "
echo -e "${YELLOW} Your Username: $(whoami) Your IP: $(hostname -I)"
echo -e "${MANGENTA} This tool is used to remotly acess different computers using ssh. "
echo -e "${MANGENTA} To leave the server/machine unse the command ${YELLOW}\"logout\" "
#normal menu options
echo Choose one option:
echo -e "${CIAN}____________________________________"
echo -e "${CIAN}| [1] |${GREEN} Create SSH connection ${CIAN} |${NC}"
echo -e "${CIAN}| [2] |${GREEN} Add a new device ${CIAN} |${NC}"
echo -e "${CIAN}| [3] |${GREEN} Remove one device ${CIAN} |${NC}"
echo -e "${CIAN}| [4] |${GREEN} Exit ${CIAN} |${NC}"
echo -e "${CIAN}|__________________________________|"
echo Option: && read option
#LOOP
#option 1, connect to a device
if [ $option -eq 1 ]; then
select_device
echo File: $selected
connect
sleep 3
menu
#option 2, create a new connection
elif [ $option -eq 2 ]; then
new_device
sleep 2
menu
#option 3, remove a stored device data
elif [ $option -eq 3 ]; then
select_device
echo File: $file
echo -e "${BLUE}Are you sure you want to delet \"$file\"? [y/n]"
read confirmation
if [ $confirmation == "y" ]; then
cd options
rm -f $file
cd ..
echo -e "${RED}File removed!${NC}"
fi
sleep 3
menu
#option 4,close the tool
elif [ $option -eq 4 ]; then
echo -e "${RED} Closing the app..."
sleep 3
exit
#to unknown input or commands
else
echo -e "${RED} Unknown command!"
sleep 2
menu
fi
} #End of the menu
#OPTION 1 AND 3
#List devices stored in "options" dir
select_device() {
cd options
base=0
commands=$(ls -A)
echo -e "${YELLOW}Select the device you want to connect:"
for file in $commands; do
echo -e "${CIAN}[$base] | ${GREEN}$file"
base=$(($base+1))
done
echo "Select one option:"
read device #user input
#select the option choosed
local base_2=0
for file in $commands; do
if [[ $base_2 == $device ]]; then
selected=$file
break
fi
base_2=$(($base_2+1))
done
cd ..
}
#OPTION 1
#connect to a stored device
connect() {
cd options
source $file # Import the variables stored in the files
echo Importing "$file" data ...
sleep 1
echo Connecting ...
sleep 1
ssh -p 22 $Username@$IP #create the connections
cd ..
}
#OPTION 2
#add a new device
new_device() {
cd options
#input
echo Choose your file name:
read file_name
echo Enter the device Username:
read username
echo Enter the device IP:
read IP
echo Enter the device passowrd:
read password
#store input
echo Creating the file...
touch $file_name.sh
echo -e Username=$username >> $file_name.sh
echo -e IP=$IP >> $file_name.sh
echo -e Password=$password >> $file_name.sh
cd ..
}
menu #call function menu
#end