Skip to content

Instantly share code, notes, and snippets.

@gfargo
Forked from learncodeacademy/deployUser.md
Last active January 11, 2019 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfargo/37889ba5954115f59f18e702bf33d01f to your computer and use it in GitHub Desktop.
Save gfargo/37889ba5954115f59f18e702bf33d01f to your computer and use it in GitHub Desktop.
Guide to a hands-off self-hosted solution for WordPress

HOSH WP

Hands-Off Self-Hosted WordPress

Using CircleCI to Deploy Your Website

  • Create Deploy User in Forge
  • Generate SSH on local machine ( No password on SSH Key )
  • Add private key to deploy service ( CircleCI )
  • Add public key to authorized hosts on target instance e.g. Digital Ocean Droplet

Generating New RSA Key https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

ssh-keygen -t rsa -C "your_email@example.com"
//OR
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Note: CirleCi does not support the default OpenSSH keys, ensure you use the following ssh-keygen -m pem params when generating an RSA key. More on generating CircleCI keys here

Finding RSA Key Fingerprint https://stackoverflow.com/questions/9607295/how-do-i-find-my-rsa-key-fingerprint

ssh-keygen -lf /path/to/ssh/key

Adding RSA Key to Authorized Keys https://stackoverflow.com/questions/12392598/how-to-add-rsa-key-to-authorized-keys-file

cat <your_public_key_file> >> ~/.ssh/authorized_keys

Copying RSA Pub Key

  • Windows
cd %userprofile%/.ssh
clip < id_rsa.pub
  • Mac OS X
pbcopy < ~/.ssh/id_rsa.pub
  • Linux
sudo apt-get install xclip
xclip -sel clip < ~/.ssh/id_rsa.pub

Login to new server as root, then add a deploy user

sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy

And Update the new password

Now login as that user

ssh deploy@url.com

Make directory .ssh on the remote server and log out

mkdir .ssh
exit

Append new ssh key to the authorized_keys file on the remote server

cat ~/.ssh/id_rsa.pub | ssh username@server.address.com 'cat >> ~/.ssh/authorized_keys'

Copying file directly to remote server

scp ~/.ssh/id_rsa.pub deploy@url.com:~/.ssh/id_rsa.pub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment