Well, WordPress 3.8 came out and its about damn time I join the modern age and setup some kind of code versioning and all that jazz. A fair amount of my clients use Capistrano, so I might take up learning some Ruby or maybe just enough to be dangerous.
Lets get down to the basics … ssh-keys. I’ve been using this site as a reference for years.
Shauns:.ssh shaun$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/shaun/.ssh/id_rsa): /Users/shaun/.ssh/shaun_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/shaun/.ssh/shaun_rsa.
Your public key has been saved in /Users/shaun/.ssh/shaun_rsa.pub.
The key fingerprint is:
The key’s randomart image is:
+–[ RSA 2048]—-+
| +.o o |
| . + + + |
| . o + . |
| . + . + . |
| * S * o E |
| . + +.o . |
| . o . . |
| . . . |
Shauns:.ssh shaun$ ls -lah
drwx—— 8 shaun staff 272B Dec 18 19:31 .
drwxr-xr-x+ 19 shaun staff 646B Dec 18 19:25 ..
-rw-r–r– 1 shaun staff 61B Dec 17 16:54 config
-rw-r–r– 1 shaun staff 415B Dec 17 16:03 known_hosts
-rw——- 1 shaun staff 1.6K Dec 18 19:31 shaun_rsa
-rw-r–r– 1 shaun staff 412B Dec 18 19:31 shaun_rsa.pub
So now we got a private key file (shaun_rsa) and public key file (shaun_rsa.pub). Now we need to copy the public up to the server. I have root access on my VM (Yay for me!), so I just cut and paste. But lets set it up for both of my vhosts:
root@shauntest:~# ls -lah /www/sites/www.nerdifymylife.com/.ssh/authorized_keys
-rw——- 1 http://www.nerdifymylife.com root 793 Dec 18 19:32 /www/sites/www.nerdifymylife.com/.ssh/authorized_keys
root@shauntest:~# ls -lah /www/sites/magento.nerdifymylife.com/.ssh/authorized_keys
-rw-r–r– 1 root root 412 Dec 18 19:33 /www/sites/magento.nerdifymylife.com/.ssh/authorized_keys
Add your IP to your firewall for the ssh port … you are using a local firewall and have moved ssh off port 22, right?
Give it a test:
Shauns:Work shaun$ ssh -i /Users/shaun/.ssh/shaun_rsa http://firstname.lastname@example.org
Shauns:Work shaun$ ssh -i /Users/shaun/.ssh/shaun_rsa email@example.com
So, that is pretty sweet but we have to type all of that out and that will get ignoring. This is where the .ssh/config file comes to the rescue. I’m going to setup some easier to use names to use …
Give it a try,
Shauns:Work shaun$ ssh nerdify-magento
Shauns:Work shaun$ ssh nerdify-www
Now that is much better, nice and simple names to use.
Next, I want to todo two things:
- Create a Git repo of both vhosts
- Backup WP and upgrade
So lets turn our html dir into a Git repo
Reinitialized existing Git repository in /www/sites/www.nerdifymylife.com/files/html/.git/
http://www.nerdifymylife.com@shauntest:~/html$ ls -lah .git/
drwxr-xr-x 8 http://www.nerdifymylife.com vhosts 4.0K Dec 18 20:21 .
drwxr-xr-x 7 http://www.nerdifymylife.com vhosts 4.0K Dec 18 19:02 ..
drwxr-xr-x 2 http://www.nerdifymylife.com vhosts 4.0K Jun 3 2013 branches
-rw-r–r– 1 http://www.nerdifymylife.com vhosts 17 Jun 3 2013 COMMIT_EDITMSG
-rw-r–r– 1 http://www.nerdifymylife.com vhosts 92 Dec 18 20:20 config
-rw-r–r– 1 http://www.nerdifymylife.com vhosts 73 Jun 3 2013 description
So, now we got some Git files (I didn’t list them all). Now, we need to commit the changes.
http://www.nerdifymylife.com@shauntest:~/html$ git commit -m “Init Git commit 12/18/2013”
[master ffa3423] Init Git commit 12/18/2013
1059 files changed, 132596 insertions(+), 24433 deletions(-)
create mode 100644 Robots.txt
create mode 100644 gatling/index.html
Chopped the output.
So, there we go … we now have the files checked in to s Git repo … doesn’t do a lot of good just sitting up there like that.
Shauns:Work shaun$ git clone ssh://firstname.lastname@example.org/~/html/ shauntest.zerolag.com/www.nerdifymylife.com/files/html/
Cloning into ‘shauntest.zerolag.com/www.nerdifymylife.com/files/html’…
remote: Counting objects: 3112, done.
remote: Compressing objects: 100% (3050/3050), done.
remote: Total 3112 (delta 899), reused 0 (delta 0)
Receiving objects: 100% (3112/3112), 16.34 MiB | 1.75 MiB/s, done.
Resolving deltas: 100% (899/899), done.
Checking connectivity… done
And just like that … we cloned the Git repo and now to do the same for the other vhost.
Now that is done, it is time to run a backup of WP so we can upgrade. See you soon!