Linux server setup: from powering on to deployment

Posted on August 24, 2014 in Web Dev

This post is more for my own use than anything else. These are common snippets I use that I’ve jotted down to jog my memory whenever I need them.

Install Git:

apt-get install git


rsync the SSH key to computer

We need to make sure the VPS is trusted from the git repo (Bitbucket, Github, etc).

Create the key:

ssh-keygen -t rsa -C ""

Then download the key:

rsync -avzh /Users/joetannorella/sites/

Then copy the contents of the key:

cat | pbcopy


To copy contents of a file from Mac

cat ~/Desktop/ded.html | pbcopy

To use an SSH key from Mac with a Nix server

Something I was getting wrong (I know this sounds ridiculous!) is that I was generating the SSH key on the SERVER side, NOT on the CLIENT side.

That was the problem.

You must generate the SSH key pair on the client side, and then transfer the public key over to the authorised file under ~/.ssh on the server.

To do this:

Generate the keypair:

ssh-keygen -t rsa

Then copy over the public key to the server. The following line assumes that no .ssh folder is present:

cat ~/.ssh/ | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"

MySql Local to Live

Export local DB to file within the local Git repo, and then sync up with Git repos so it’s on the live server.

Log in to MySql:

mysql -u <user> -p

Then load the SQL from the file now on the live server. From the current directory:

mysql> source sqlfile.sql

Rsync using a non-standard port (for shared hosting)

rsync -avzh -e "ssh -p <port>" <user>@<server>:<server_file_location> <local_destination_location>

WordPress file persmissions

sudo chown -R www-data:www-data public

Leave a comment

Was this helpful? Did I miss something? Do you have a question? Get in touch, or tell me below.