Terrform configuration for gophsih/postfix stmp server on multiple providers FILE cloud_init.cfg
- Libvirt - localhost
- AWS
- Azure
- Civo
Aim is to spin up bare servers and use cloud_init.cfg for identical config across all providers.
- Set instance and resource variables in
variables.tf
ESPECIALLY THE CLOUD INIT FILE cloud_init.cfg in main.tf line 10 - Run the following:
terraform init
terraform plan
terraform apply
virsh net-dhcp-leases ${VM_HOSTNAME}_network
ssh ${VM_USER}@ip_address
service --status-all
sudo tail cloud-init.log
cd /var/log sudo tail -n 200 cloud-init-output.log
cd /var/log sudo tail mail.log
get ip address (e.g. 10.10.10.179) and call 'https://:3333' in browser
to send test email with gmail as the final relay from gophish, setup the following in cloud_init.cfg (currently at line 30), ensure the gmail account you use has less_secure apps enabled. The format is user:password for gmail.
write_files:
- path: /etc/postfix/sasl_passwd
content: |
[smtp.gmail.com]:587 gmail_username:gmail_password
owner: root:root
permissions: 0400
In the sending profile at '/sending_profiles' fill in:
Name <profile name, can be anything> From Host: localhost: 25
You can leave the other fields blank. Send a test email to your own email address, you should receive an email with subject 'Default Email from Gophish'. This demonstrates that you are sending an email through postfix (localhost:25) to smtp.gmail.com, and then on to your mailbox.
Issues can be tracked in the logs referenced above.
terraform destroy
http://flurdy.com/docs/postfix/ https://www.exratione.com/2019/02/a-mailserver-on-ubuntu-18-04-postfix-dovecot-mysql/ https://www.linuxbabe.com/mail-server/setup-basic-postfix-mail-sever-ubuntu
https://www.linuxbabe.com/mail-server/ubuntu-18-04-iredmail-email-server