|
# offer to fetch and store github public keys in authorized_keys file |
|
fetch_github_key() |
|
{ |
|
mkdir -p ~/.ssh |
|
if ! [[ -f ~/.ssh/authorized_keys ]]; then |
|
touch ~/.ssh/authorized_keys |
|
fi |
|
chmod 700 ~/.ssh |
|
chmod 600 ~/.ssh/* |
|
|
|
read -p "Enter Github Username: " github_username |
|
curl -s https://github.com/${github_username}.keys >> ~/.ssh/authorized_keys |
|
} |
|
|
|
read -t 10 -p "Download github public key for ssh? (Y/n): " REPLY |
|
if [ $? -gt 128 ]; then |
|
echo "Timed out waiting for input. Defaulting to N!" |
|
break |
|
fi |
|
|
|
case $REPLY in |
|
[yY]*) |
|
fetch_github_key |
|
;; |
|
*) |
|
;; |
|
esac |
|
|
|
# offer to setup gmail for outgoing smtp messages |
|
# https://geekistheway.com/2021/03/07/configuring-e-mail-alerts-on-your-proxmox/ |
|
setup_smtp_to_gmail() |
|
{ |
|
apt update |
|
apt install -y libsasl2-modules |
|
|
|
echo "You will need to go to https://security.google.com/settings/security/apppasswords to generate an app password!" |
|
echo "" |
|
read -p 'Gmail username (without @gmail.com): ' YOUR_GMAIL_USERNAME |
|
read -sp 'Gmail App Password: ' YOUR_GMAIL_APP_PASSWORD |
|
|
|
echo "smtp.gmail.com $YOUR_GMAIL_USERNAME@gmail.com:$YOUR_GMAIL_APP_PASSWORD" > /etc/postfix/sasl_passwd |
|
postmap hash:/etc/postfix/sasl_passwd |
|
chmod 600 /etc/postfix/sasl_passwd |
|
|
|
sed -i 's/relayhost\ =/relayhost\ =\ smtp.gmail.com:587/g' /etc/postfix/main.cf |
|
|
|
tee -a /etc/postfix/main.cf >/dev/null <<'EOF' |
|
smtp_use_tls = yes |
|
smtp_sasl_auth_enable = yes |
|
smtp_sasl_security_options = |
|
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd |
|
smtp_tls_CAfile = /etc/ssl/certs/Entrust_Root_Certification_Authority.pem |
|
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache |
|
smtp_tls_session_cache_timeout = 3600s |
|
EOF |
|
|
|
postfix reload |
|
|
|
echo "Proxmox test message $(date)" | mail -s "Proxmox Test from $(hostname)" $YOUR_GMAIL_USERNAME@gmail.com |
|
} |
|
|
|
read -t 10 -p "Setup gmail for outgoing smtp mail messages? (Y/n): " REPLY |
|
if [ $? -gt 128 ]; then |
|
echo "Timed out waiting for input. Defaulting to N!" |
|
break |
|
fi |
|
|
|
case $REPLY in |
|
[yY]*) |
|
setup_smtp_to_gmail |
|
;; |
|
*) |
|
;; |
|
esac |