§2023-04-15

¶ By ChatGPT

  • First, make sure that you have an SSH key pair. You can check for existing keys by running the command ls -al ~/.ssh. If you don't have an SSH key pair, you can generate one by following the steps in GitHub's documentation.

  • Once you have an SSH key pair, you need to add your public key to your GitHub account. To do this, siogn into to your GitHub account settings, click on "SSH and GPG keys," and then click on "New SSH key." Copy and paste your public key into the "Key" field, and then give your key a descriptive title.

    • alexlai@yushei.met, TxxxxYxxLxx#1nnn
    • or,
    $ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/alexlai/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/alexlai/.ssh/id_rsa
    Your public key has been saved in /home/alexlai/.ssh/id_rsa.pub
    The key fingerprint is:
    SHA256:jjCHKPT6o5l/V0l7EXomCk3ZBUhYSqqJo+O25eqI+wo alexlai@hc4Jammy
    The key's randomart image is:
    +---[RSA 3072]----+
    |     .+o+.o.     |
    |    o..+ . .     |
    | . . .o   . .    |
    |o +. o . + +     |
    |+o..+ o S * .    |
    |.o.  + + + .     |
    |E. .  . o .      |
    |=o*. . .         |
    |B%*+o .          |
    +----[SHA256]-----+
    
  • Now that your public key is added to your GitHub account, you can configure Git to use SSH instead of HTTPS for authentication. Open up a terminal window and enter the following command:

git remote set-url origin git@github.com:<username>/<repository>.git

Replace with your GitHub username and with the name of the repository you want to work with.

That's it! You should now be able to use Git with SSH authentication for your GitHub repositories. You can test this by running a command like git push or git pull and seeing if it works without prompting you for a password.

¶Setup to compile caddy

  1. Setup dir
$ mkdir caddy_compile && cd $_
$ git init
$  v
alexlai@hc4Jammy:~/build/caddy_compile$ git remote set-url origin git@github.com:alexlai@yushei.me/cloudflare.git

$ git remote set-url origin git@github.com:alexlai@yushei.me/caddy.git


$ xcaddy build --with github.com/caddy-dns/cloudflare --with github.com/caddyserver/format --with github.com/caddyserver/replace --with github.com/caddyserver/rewrite --with github.com/caddyserver/templates --with github.com/caddyserver/caddy-limits --with github.com/caddyserver/caddy-lua --with github.com/caddyserver/caddy-jwt --with github.com/mholt/caddy-webdav --with github.com/caddyserver/realip --with github.com/caddyserver/forwardproxy --with github.com/mholt/caddy-threads --with github.com/sjtug/caddy2-filter --with github.com/greenpau/caddy-auth-jwt --with github.com/greenpau/caddy-auth-portal --with github.com/greenpau/caddy-trace --with github.com/greenpau/caddy-authorize --with github.com/greenpau/caddy-cors --with github.com/caddyserver/markdown
I have to compile the caddy using "xcaddy --with github.com/caddyserver/format".  How to setup for example, "git remote set-url origin git@github.com:alexlai@yushei.me/xxx.git" ,  xxx.git please replace with the right one. So that it will use ssh method instead of http method to fetch source from github.
Return to Top