mirror of
https://github.com/thelittlerocket/pve.git
synced 2025-01-31 18:18:28 +08:00
Update ssh.sh
This commit is contained in:
parent
b6be693ced
commit
fa26e42cbf
1 changed files with 22 additions and 7 deletions
|
@ -99,13 +99,28 @@ if [ -f "/etc/selinux/config" ]; then
|
|||
sed -i.bak '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
|
||||
fi
|
||||
setenforce 0;
|
||||
sed -i "s/^#\?Port.*/Port $sshport/g" /etc/ssh/sshd_config;
|
||||
sed -i "s/^#\?PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config;
|
||||
sed -i "s/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config;
|
||||
sed -i 's/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/' /etc/ssh/sshd_config
|
||||
sed -i 's/#ListenAddress ::/ListenAddress ::/' /etc/ssh/sshd_config
|
||||
sed -i 's/#AddressFamily any/AddressFamily any/' /etc/ssh/sshd_config
|
||||
sed -i '/^#UsePAM\|UsePAM/c #UsePAM no' /etc/ssh/sshd_config
|
||||
if [ -f /etc/ssh/sshd_config ]; then
|
||||
sed -i "s/^#\?Port.*/Port $sshport/g" /etc/ssh/sshd_config
|
||||
sed -i "s/^#\?PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config
|
||||
sed -i "s/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config
|
||||
sed -i 's/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/' /etc/ssh/sshd_config
|
||||
sed -i 's/#ListenAddress ::/ListenAddress ::/' /etc/ssh/sshd_config
|
||||
sed -i 's/#AddressFamily any/AddressFamily any/' /etc/ssh/sshd_config
|
||||
sed -i '/^#UsePAM\|UsePAM/c #UsePAM no' /etc/ssh/sshd_config
|
||||
sed -i "s/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g" /etc/ssh/sshd_config
|
||||
sed -i '/^AuthorizedKeysFile/s/^/#/' /etc/ssh/sshd_config
|
||||
fi
|
||||
if [ -f /etc/ssh/sshd_config.d/50-cloud-init.conf ]; then
|
||||
sed -i "s/^#\?Port.*/Port $sshport/g" /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
sed -i "s/^#\?PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
sed -i "s/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
sed -i 's/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/' /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
sed -i 's/#ListenAddress ::/ListenAddress ::/' /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
sed -i 's/#AddressFamily any/AddressFamily any/' /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
sed -i '/^#UsePAM\|UsePAM/c #UsePAM no' /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
sed -i "s/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g" /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
sed -i '/^AuthorizedKeysFile/s/^/#/' /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
fi
|
||||
remove_duplicate_lines "/etc/ssh/sshd_config"
|
||||
service ssh restart
|
||||
service sshd restart
|
||||
|
|
Loading…
Reference in a new issue