The following information is for Vultr/ServerPilot and BitBucket users. In principle the following should apply for any server/git combination, but with variations. This information specifically applies to Ubuntu 16.04.
SSH into your Vultr server using your serverpilot
user.
ssh [email protected]
cd ~/.ssh/
ssh-keygen -t rsa
Enter your key name, for example bitbucket_rsa
. You do not need to add a password. If you plan to use a deployment script that fetches your repo automatically then do not add a password.
cd ~/.ssh/
nano config
Paste in the following
Host bitbucket.org
IdentityFile ~/.ssh/bitbucket_rsa
Rename bitbucket_rsa
if you have named it differently.
crlt+x
to exit, press ENTER
to save.
Echo the public key code to screen and copy
.
cd ~/.ssh/
cat bitbucket_rsa.pub
Open your browser and visit bitbucket.org
> Select Repository
> Settings
> Access Keys
> Add Key
Give your key a name, for example Vultr Server
and paste
in your public key.
cd ~/apps/your-app/
mkdir tmp
cd /tmp
git clone [email protected]:username/repo.git .
It should fetch your repository without the need for a password. You can tidy up by safely deleting the tmp
directory with rm -rfv tmp/