Skip to content

Instantly share code, notes, and snippets.

@Iuriy-Budnikov
Last active February 27, 2017 11:35
Show Gist options
  • Save Iuriy-Budnikov/8efa2b1604aa79017c5994e0d27aa5dc to your computer and use it in GitHub Desktop.
Save Iuriy-Budnikov/8efa2b1604aa79017c5994e0d27aa5dc to your computer and use it in GitHub Desktop.

Setting up SSH Keys

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

Now login as that user

ssh [email protected]

You can temporary enable password authentication

sudo nano /etc/ssh/sshd_config

Find out PasswordAuthentication to yes:

PasswordAuthentication yes

Save file and exit editor. It requires you to restart SSH service:

sudo systemctl restart sshd

Install git

sudo apt-get install git 
sudo apt-get install git-core

Make directory .ssh on the remote server and log out

mkdir .ssh
exit

Push your ssh key to the authorized_keys file on the remote server

scp ~/.ssh/id_rsa.pub [email protected]:~/.ssh/authorized_keys

Create the RSA Key Pair

ssh-keygen -t rsa

Run git agent

eval `ssh-agent`
ssh-add ~/.ssh/id_rsa

Add deployment key for server

ssh -T [email protected]
ssh -T [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment