notes/ssh.md

2.2 KiB

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