On Windows, be sure you’re using Git Bash to perform these. I’m going to say SSH keys are stored in ~/.ssh/foundations_key, but just remember yours is at ~/Desktop/foundations_key.

Connecting to your server

You give it your foundations_key private key to confirm who you are, along with giving it the IP address and the username (which is always root).

ssh -i ~/.ssh/foundations_key root@1.2.3.4

Disconnecting from your server

That’s easy!

exit

If you type that when you’re on your own machine you’ll close out your terminal/command prompt.

Sending files to/from your server

You’ll use scp - secure copy - to send files to your server.

scp -i ~/.ssh/foundations_key local_file.py root@1.2.3.4:
  • If the file is in Downloads or on your Desktop, you can do something like ~/Desktop/local_file.py
  • If you wanted to rename your file, you could do root@1.2.3.4:other_filename.py.

If you want to download a file from your server, you just change around the source and destination.

scp -i ~/.ssh/foundations_key root@1.2.3.4:remote_file.py . 

I used . to mean “Download the file into my current directory,” but you could also tell it to download the file into, say, Downloads, too.

scp -i ~/.ssh/foundations_key root@1.2.3.4:remote_file.py ~/Downloads 

Crontab

To open up the cron editor, run

crontab -e

You’re probably using nano. I hope you’re using nano. Use the arrow keys to move around and just type when you want to type. Ctrl+X to start the process of exiting (then press y and hit enter to agree to save it).

The Wikipedia page for cron is actually pretty good. Your commands will be something like

* * * * * python3 myfile.py

Except that does things every minute!

If your server says “You have new mail”

New mail means you screwed something up with your cron job. Every time your cron job creates output - whether your Python script is printing to the screen, or you’re getting an error message - it sends your server an email.

It’s basically a fake email. It’s an email from your server, to your server, and it never touches the internet.

To check this email, type mail. Then hit Enter to read the email. Keep hitting enter to read more emails, or type x to edit. The email should give you the error message you’re getting.

If it’s python: command not found it’s because on the server you need to use python3 instead of python, because That’s The Way It Is.

To delete all of these fake emails, before you exit type d * and hit enter.