mirror of
https://github.com/idanoo/m2.nz.git
synced 2024-11-22 16:25:13 +00:00
update tokens
This commit is contained in:
parent
59e6055f78
commit
12409675a2
@ -9,31 +9,31 @@ if [[ "$1" == "uninstall" ]]; then
|
|||||||
sudo rm -fr /usr/local/bin/check_keys
|
sudo rm -fr /usr/local/bin/check_keys
|
||||||
sed -i 's/^AuthorizedKeysCommand/#&/' /etc/ssh/sshd_config
|
sed -i 's/^AuthorizedKeysCommand/#&/' /etc/ssh/sshd_config
|
||||||
sed -i 's/^AuthorizedKeysCommandUser/#&/' /etc/ssh/sshd_config
|
sed -i 's/^AuthorizedKeysCommandUser/#&/' /etc/ssh/sshd_config
|
||||||
exit;
|
sudo systemctl restart {sshd,ssh}
|
||||||
elif [[ "$1" == "update" ]]; then
|
|
||||||
wget -q -O /tmp/authorized_keys https://m2.nz/authorized_keys || curl -sSo /tmp/authorized_keys https://m2.nz/authorized_keys
|
|
||||||
exit;
|
exit;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Write script
|
# Write script to pull/login
|
||||||
sudo cat << EOF > /usr/local/bin/check_keys
|
sudo cat << EOF > /usr/local/bin/check_keys
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Check if we have it cached, if so use that
|
# Attempt to pull new keys
|
||||||
if test -f "/tmp/authorized_keys"; then
|
KEYS=$(wget -q -O /etc/ssh/temp/credshttps://m2.nz/authorized_keys || curl -sSo /etc/ssh/temp/creds https://m2.nz/authorized_keys)
|
||||||
cat /tmp/authorized_keys
|
if [[ "$KEYS" == ssh* ]]; then
|
||||||
|
echo $KEYS > /etc/ssh/temp/creds
|
||||||
# update for next login
|
|
||||||
bash /usr/local/bin/check_keys update &
|
|
||||||
else
|
|
||||||
wget -q -O /tmp/authorized_keys https://m2.nz/authorized_keys || curl -sSo /tmp/authorized_keys https://m2.nz/authorized_keys
|
|
||||||
cat /tmp/authorized_keys
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cat /etc/ssh/temp/creds
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Make executable
|
# Make executable
|
||||||
sudo chmod +x /usr/local/bin/check_keys
|
sudo chmod +x /usr/local/bin/check_keys
|
||||||
|
|
||||||
|
# Generate temp directory
|
||||||
|
sudo mkdir -p /etc/ssh/temp
|
||||||
|
sudo chown nobody:nogroup -R /etc/ssh/temp
|
||||||
|
|
||||||
# Trigger on initial run
|
# Trigger on initial run
|
||||||
/usr/local/bin/check_keys
|
/usr/local/bin/check_keys
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user