sync/zsh/config.zsh

24 lines
1.1 KiB
Bash
Raw Normal View History

2016-07-16 15:48:23 -04:00
copy_ssh_keys() {
cat ~/.ssh/authorized_keys | ssh $* '(test -f ~/.ssh/id_rsa || ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N "") </dev/null && cat > ~/.ssh/authorized_keys'
echo -n "Testing..."
ssh -o PasswordAuthentication=no $* 'echo Success'
}
2016-07-18 15:54:54 -04:00
secure_ssh() {
echo "Copying script over..."
ssh $* 'cat > /tmp/script.sh' <<'EOF'
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
2016-07-26 23:06:22 -04:00
sed -ri'' 's/^(\s*IgnoreRhosts\s)/#\1/gI' /etc/ssh/sshd_config
2016-07-18 15:54:54 -04:00
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
2016-07-26 23:06:22 -04:00
(echo -e "Protocol 2\nUseDNS no\nPermitEmptyPasswords no\nPermitRootLogin no\nIgnoreRhosts yes";cat /etc/ssh/sshd_config)>/tmp/sshd_config
2016-07-18 15:54:54 -04:00
mv /tmp/sshd_config /etc/ssh/sshd_config
diff -urN /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
2016-08-18 00:57:47 -04:00
echo Errors:
sshd -t && echo None
2016-07-18 15:54:54 -04:00
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'
}