Skip to content

Instantly share code, notes, and snippets.

@jcunanan05
Last active January 19, 2020 03:01
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 jcunanan05/d48f5e99aaa9a69a0b6d89a7ae4a9d70 to your computer and use it in GitHub Desktop.
Save jcunanan05/d48f5e99aaa9a69a0b6d89a7ae4a9d70 to your computer and use it in GitHub Desktop.
My notes on how to setup a ssh connection to a VPS in windows

Requirements

  • Git Bash
  • VPS to put the generated private key

Generate SSH key on your machine

  1. Open your git bash
  2. cd /c/Program Files/Git/etc/ssh
  3. run ssh-keygen, name your key (id_rsa is default) then enter enter..
  4. copy the contents of file with .pub

Paste the pub key contents in your VPS ssh authorized keys

  1. Login on your vps via console (in case for me digital ocean console), and paste the .pub contents to a file authorized_keys in ~/.ssh/
  2. Save. (For me my editor is vim so i use the command sudo vi ~/.ssh/authorized_keys)

Add your vps in your local ssh_config

  1. Your generated pub key and private key should be in /c/Program Files/Git/etc/ssh. Copy folder contents in c:/.ssh/. Make a folder if it doesn't exist
  2. Paste in the file ssh_config at Program Files/Git/etc/ssh
Host hello
    HostName example.com
    IdentityFile /c/.ssh/blahblah_rsa
    AddKeysToAgent yes
  1. That way, you can run ssh username@hello and it will work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment