From 7e84cde9d716f76705892bcdba9ab18a989f21a9 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Fri, 14 May 2021 15:50:44 -0400 Subject: [PATCH] notes on setting up ssh keys for git usage --- ssh.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 ssh.md diff --git a/ssh.md b/ssh.md new file mode 100644 index 0000000..ceea352 --- /dev/null +++ b/ssh.md @@ -0,0 +1,59 @@ +SSH keys are generated by the openSSH program and are usually stored in `.ssh` folder of the home directory for the user. +* Windows: `C:\Users\PTrowbridge\.ssh` +* NIX `//home/pt/.ssh` + +If there is nothing there you can create keys by doing `ssh-keygen` like so: +``` + sshdemo@USHCC10107:~$ ssh-keygen + Generating public/private rsa key pair. + Enter file in which to save the key (/home/sshdemo/.ssh/id_rsa): + Created directory '/home/sshdemo/.ssh'. + Enter passphrase (empty for no passphrase): + Enter same passphrase again: + Your identification has been saved in /home/sshdemo/.ssh/id_rsa. + Your public key has been saved in /home/sshdemo/.ssh/id_rsa.pub. + The key fingerprint is: + SHA256:DpV1961Dec5/vmASwdu8eYPp1UXi4QOku6LJeVoSz3o sshdemo@USHCC10107 + The key's randomart image is: + +---[RSA 2048]----+ + | . o . | + | o.+ . o.| + | o .o. = =| + | . .== O | + | o S .o o* +| + | * .. =o+| + | . * .. B ++| + | . BE. + +.o| + | B+ . .o| + +----[SHA256]-----+ + sshdemo@USHCC10107:~$ +``` + +if you chose to use a passphrase you will have to enter the passphrase once whenever you (login/boot?) + +Here's the folder and files it created: +``` + sshdemo@USHCC10107:~$ cd .ssh/ + sshdemo@USHCC10107:~/.ssh$ ll + total 4 + drwx------ 1 sshdemo sshdemo 512 May 14 15:38 ./ + drwxr-xr-x 1 sshdemo sshdemo 512 May 14 15:38 ../ + -rw------- 1 sshdemo sshdemo 1766 May 14 15:38 id_rsa + -rw-r--r-- 1 sshdemo sshdemo 400 May 14 15:38 id_rsa.pub + sshdemo@USHCC10107:~/.ssh$ +``` + +the `id_rsa.pub` file is the public key. +if you copy the contents to your profile on a git server, you can use ssh to connect instead of having to use user/pass with http. +usually you log into the website and go to setting for your profile. + +after loading the public key to your public profile can clone the repo using ssh. +to target an alternate port you will have to manually do a remote add: + +`git clone ssh://git@gitea.hptrow.me:port_num_here/pt/notes` + +or if the repo is already setup you can: + +``git remote add hptrow ssh://git@gitea.hptrow.me:port_num_here/pt/notes` + +now you can `git push` without any password prompt