Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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