Instructions on how to set up a script to send an email with your IP in Ubuntu
-
Move to the folder where we will set the scripts
cd /usr/local/bin -
sudo apt-get update sudo apt-get install sendemail -
Download the code from github
sudo git clone https://github.com/esdandreu/send-email-with-ip.git -
Navigate to the repository
cd /usr/local/bin/send-email-with-ip/ -
Make the main script executable
sudo chmod a+xrw send-email-with-ip.sh -
Create the
.envfile with your data: Open the file with your favourite editor. In my case it isneovimwhich can be installed withsudo apt install neovimand then runsudo vim .envto open it the file. Once you are editing.env, write:export EMAIL="less_secure_email@gmail.com" export PASSWORD="password" export TO="my_email@gmail.com"Make sure that the
EMAILyou wrote allows less secure apps. -
Modify the cronjobs
crontab -eChoose an editor in the command line and add a line with:
@reboot sleep 60; /usr/local/bin/send-email-with-ip/send-email-with-ip.sh
Now everything is set up. Reboot and check!