Hands-Off Self-Hosted WordPress
- 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
cd %userprofile%/.ssh
clip < id_rsa.pub
pbcopy < ~/.ssh/id_rsa.pub
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