Added secure_ssh
This commit is contained in:
parent
75c9003635
commit
cd814408d1
@ -3,3 +3,20 @@ copy_ssh_keys() {
|
|||||||
echo -n "Testing..."
|
echo -n "Testing..."
|
||||||
ssh -o PasswordAuthentication=no $* 'echo Success'
|
ssh -o PasswordAuthentication=no $* 'echo Success'
|
||||||
}
|
}
|
||||||
|
secure_ssh() {
|
||||||
|
echo "Copying script over..."
|
||||||
|
ssh $* 'cat > /tmp/script.sh' <<'EOF'
|
||||||
|
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
|
||||||
|
sed -ri'' 's/^(\s*Protocol\s)/#\1/gI' /etc/ssh/sshd_config
|
||||||
|
sed -ri'' 's/^(\s*UseDNS\s)/#\1/gI' /etc/ssh/sshd_config
|
||||||
|
sed -ri'' 's/^(\s*PermitEmptyPasswords\s)/#\1/gI' /etc/ssh/sshd_config
|
||||||
|
sed -ri'' 's/^(\s*PermitRootLogin\s)/#\1/gI' /etc/ssh/sshd_config
|
||||||
|
(echo -e "Protocol 2\nUseDNS no\nPermitEmptyPasswords no\nPermitRootLogin no";cat /etc/ssh/sshd_config)>/tmp/sshd_config
|
||||||
|
mv /tmp/sshd_config /etc/ssh/sshd_config
|
||||||
|
diff -urN /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
|
||||||
|
sshd -t
|
||||||
|
mv /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
|
||||||
|
EOF
|
||||||
|
echo "Running script..."
|
||||||
|
ssh -t $* 'chmod +x /tmp/script.sh;command -v sudo >/dev/null 2>&1 && sudo /tmp/script.sh || /tmp/script.sh;rm /tmp/script.sh'
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user