Skip to content

Instantly share code, notes, and snippets.

@saetia
Created December 27, 2011 22:05
Show Gist options
  • Select an option

  • Save saetia/1525301 to your computer and use it in GitHub Desktop.

Select an option

Save saetia/1525301 to your computer and use it in GitHub Desktop.
per user SSH

replace {{placeholders}} with your own values

On local machine

Generate a key

ssh-keygen -f {{identification}} -t rsa -q
ssh-add -K {{identification}}

Create .ssh directory and change permissions and owner

cat ~/.ssh/{{identification}}.pub | ssh [email protected] "mkdir /var/www/vhosts/{{site}}/.ssh && chown {{user}} /var/www/vhosts/{{site}}/.ssh && chmod 700 /var/www/vhosts/{{site}}/.ssh"

Send over your public key

cat ~/.ssh/{{identification}}.pub | ssh {{user@server}} "cat > ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

Send over your public key (If authorized_keys already exist)

cat ~/.ssh/{{identification}}.pub | ssh {{user@server}} "cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment