Last part I learned how to add new cron jobs to my Linux server. This part, I’m automating pulls from a Github repository.
First, I added the Two Factor Authentication to my Github account. I’m guilty for not doing this before. It’s an easy step to do.
Click on your Avatar -> Settings -> Security
Then you’ll find the option to add the TFA.
Next, I proceeded to add a SSH Key. I’ve done this before on my recent PC (The one with Windows 10 D:), but not on this computer (The one with Ubuntu :D).
All I had to do was type the command
ssh-keygen -t rsa -b 4096 -C "juliapaola97@gmail.com"
Then I added a passphrase and that was it.
Then I added the SSH key on Github. To test it, I cloned the repository I have for the course using SSH:
The repository was successfully cloned.
Automating Pulls
After this configuration, it’s time to automate our pulls. In order to do this, I added a new shell file, automate_pull.sh. The file was the following content:
What it does? It goes to the repository directory and executes a pull.
Now, all we have to do is add a crontab to execute the automate_pull.sh file. We run the command:
crontab -e
Then, just edit the file with the desired configuration. I decided to run the file everyday at midnight: