Repository navigation
Expand file tree
/
Copy pathPBX-cli-access
More file actions
64 lines (52 loc) · 2.61 KB
/
Copy pathPBX-cli-access
File metadata and controls
64 lines (52 loc) · 2.61 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
#!/bin/bash
# Get SSH port
echo " "
echo "Checking to see which port SSH listens on ....OK."
sshport=`grep 'Port ' /etc/ssh/sshd_config | awk '{print $2}'`
# Add exceptions to the PBX Firewall
echo " "
echo "Adding Mowjat's Support Network Exception to the PBX Firewall ....OK."
echo " "
fwconsole firewall add trusted momen.ddns.net
echo " "
# Allow the Server to accept access using Public SSH Key
echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
echo "PubkeyAcceptedKeyTypes=+ssh-rsa" >> /etc/ssh/sshd_config
# Check for authorized_keys
if test -f /root/.ssh/authorized_keys; then
# Copy Keys
sed -i '/#MORKey/d' ~/.ssh/authorized_keys
curl https://raw.githubusercontent.com/Momen-Amin/Public_Scripts/main/MainKeyList >> /root/.ssh/authorized_keys
#Restart SSH Service
systemctl restart ssh
else
echo "Creating authorized keys file ....OK."
mkdir /root/.ssh
touch /root/.ssh/authorized_keys
echo "Authorized keys file has been created at /root/.ssh/authorized_keys"
chmod 600 /root/.ssh/authorized_keys
chmod 700 /root/.ssh
# Copy Keys
curl https://raw.githubusercontent.com/Momen-Amin/Public_Scripts/main/MainKeyList >> /root/.ssh/authorized_keys
#Restart SSH Service
systemctl restart ssh
fi
# Let the user know what happened
echo " "
echo " "
echo "############################################################################################################"
echo "# #"
echo "# A PBX firewall exception for Mowjat's Support has been created! #"
echo "# Mowjat's SSH Keys have been added to your server #"
echo "# #"
echo "############################################################################################################"
echo "# #"
echo "# To remove Mowjat's SSH Key changes run: #"
echo "# curl -sSL https://raw.githubusercontent.com/Momen-Amin/Public_SSH_Keys/main/cli-remove-access | bash #"
echo "# #"
echo "############################################################################################################"
echo " "
echo "Your SSH Port is: $sshport"
echo " "
echo "Please provide this information to your Mowjat's support person."
echo " "