added install ssh script
This commit is contained in:
parent
c7d0275915
commit
42dc7ba207
62
protected_resources/scripts/install-config-ssh.sh
Normal file
62
protected_resources/scripts/install-config-ssh.sh
Normal file
@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
if which ssh >/dev/null 2>&1; then
|
||||
echo "SSH is installed"
|
||||
exit 1
|
||||
else
|
||||
echo "SSH is not installed"
|
||||
fi
|
||||
|
||||
if lsb_release -a 2>/dev/null | grep -q -E "Debian|Ubuntu"; then
|
||||
echo "Running Debian or Ubuntu"
|
||||
apt-get install openssh-server
|
||||
systemctl start sshd
|
||||
|
||||
elif cat /etc/os-release 2>/dev/null | grep -q -i "alpine"; then
|
||||
echo "Running Alpine"
|
||||
|
||||
# Stop and remove Dropbear
|
||||
rc-service dropbear stop
|
||||
rc-update del dropbear
|
||||
apk del dropbear* -f
|
||||
|
||||
# Stop and remove SSHD
|
||||
rc-service sshd stop
|
||||
rc-update del sshd
|
||||
apk del openssh* -f
|
||||
|
||||
# Clean up Dropbear and SSH configurations
|
||||
rm -rf /etc/dropbear
|
||||
rm -rf /etc/ssh
|
||||
rm /etc/init.d/ssh
|
||||
|
||||
# Reboot now if needed
|
||||
# reboot now
|
||||
|
||||
# Install OpenSSH and necessary packages
|
||||
apk add openssh gcompat libstdc++ curl bash git grep
|
||||
apk add procps --no-cache
|
||||
|
||||
# Start and add SSHD to startup
|
||||
rc-service sshd start
|
||||
rc-update add sshd
|
||||
|
||||
# Update AllowTcpForwarding setting
|
||||
sed -i 's/^#*AllowTcpForwarding.*/AllowTcpForwarding yes/' /etc/ssh/sshd_config
|
||||
|
||||
# Update PermitTunnel setting
|
||||
sed -i 's/^#*PermitTunnel.*/PermitTunnel yes/' /etc/ssh/sshd_config
|
||||
|
||||
# Uncomment the line if needed (remove '#' at the beginning)
|
||||
sed -i 's/^#PermitTunnel.*/PermitTunnel yes/' /etc/ssh/sshd_config
|
||||
|
||||
# Restart the SSH service to apply the changes
|
||||
/etc/init.d/sshd restart
|
||||
|
||||
else
|
||||
echo "Unknown distribution"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set PermitRootLogin to prohibit-password
|
||||
sed -i 's/^#*PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
|
@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
if which docker >/dev/null 2>&1; then
|
||||
echo "Docker is installed"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user