Skip to content

Latest commit

 

History

History
80 lines (59 loc) · 1.95 KB

Github-SSH.md

File metadata and controls

80 lines (59 loc) · 1.95 KB
  1. Open Terminal.

  2. Change the current working directory to your local project.

  3. List your existing remotes in order to get the name of the remote you want to change.

    $ git remote -v
    > origin  [email protected]:OWNER/REPOSITORY.git (fetch)
    > origin  [email protected]:OWNER/REPOSITORY.git (push)
  4. Change your remote's URL from SSH to HTTPS with the git remote set-url command.

    git remote set-url origin https://github.com/OWNER/REPOSITORY.git
  5. Verify that the remote URL has changed.

    $ git remote -v
    # Verify new remote URL
    > origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    > origin  https://github.com/OWNER/REPOSITORY.git (push)

Create SSH public and private keys

$ cd ~/.ssh
$ ls ...
ssh-keygen -t ed25519 -C "[email protected]"
ssh-keygen -t rsa -b 4096 -C "[email protected]"
$ cat id_ed25519
$ cat id_ed25519.pub
$ ssh -T [email protected]

Git Remote

$ git remote -v
origin	https://github.com/Hacker-Code-J/MyObsidianMemo.git (fetch)
origin	https://github.com/Hacker-Code-J/MyObsidianMemo.git (push)
            
$ git remote set-url origin [email protected]:Hacker-Code-J/MyObsidianNote.git
origin	[email protected]:MyObsidianNote.git (fetch)
origin	[email protected]:MyObsidianNote.git (push)

Blocking Port

Alternate Ports: If your network is blocking port 22, GitHub also supports SSH connections through port 443. You can modify your SSH configuration to use this alternative port by adding the following lines to your ~/.ssh/config file:

$ ~/.ssh
$ touch config
$ nvim config
Host github.com
  Hostname ssh.github.com
  Port 443
  User git
$ cat config