This doesn’t have a lot to do with Python, machine learning, spirographs or hardball doubles. But, in trying to get something working in aid of my friend’s blog, it looks like I will need to use multiple (well two) GitHub accounts on my development pc. And, I figure I best document what I try and what works—if it ever works.

Also I wish to continue using SSH to avoid the need to provide a password for everything I do.

Current SSH Keys

I started by looking at what SSH keys I had. But it looks like I need to use git bash. So, I am going to add git bash to terminal settings.

Add Git Bash to Terminal

I determined the path to the executable, by getting the properties of the git bash shortcut. In the Start menu, I navigate to the Git entry and opened it. I right clicked the Git Bash icon, selected More and then Open file location. Which took me to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git. I then right clicked the Git Bash shortcut and selected Properties. The shortcut’s target was: E:\appDev\Git\git-bash.exe --cd-to-home.

Then in an open terminal, I used the ‘down arrow’ to select Settings. Then down at the bottom of the settings menu, I selected ‘Add a new profile’. And then ‘New empty profile’.

I filled in the bits and pieces (Name: Git Bash, Command line: E:\appDev\Git\git-bash.exe, Tab title: Git Bash). I added an icon by getting the path too the current icon from the shortcut properties (‘Change Icon’ button).

Unfortunately that target, when selected, opened Git Bash in a new command window. Not in a new terminal tab. The solution was to change the target to E:\appDev\Git\bin\bash.exe.

Existing Keys

In a Git Bash tab I entered the following: cd ~/.ssh. That moved me to appropriate directory. Then ls -al showed me the current SSH key files.

Git Bash in Windows Terminal listing of current SSH files

The default name for the GitHub SSH keys is id_rsa. id_rsa.pub contains my public key. id_rsa contains my private (i.e. secret) key.

Add New Key(s)

I am going to need at least one more key for GitHub. But it will need its own name. I will use lb_dbls. But first I need to open a Terminal with admin privileges before opening the Git Bash tab. I failed to do so the first time.

I then ran ssh-keygen -t ed25519 -C "lynn@###.ca" -f "lb_dbls" in the bash tab.

Create new SSH key in Git Bash in Windows Terminal

Won’t bother with an updated directory listing. But the two SSH key files are there.

Because my SSH is using an older encryption algorithm I decided to update it. The file name has defaulted to id_ed25519. Bit of a pain I guess, but such is life.

Add My New Key to GitHub Account and ssh-agent

I will start with my account and see if things continue to work.

I first copied the public key to the clipboard using: Get-Content C:\Users\bark\.ssh\id_ed25519.pub | Set-Clipboard.

Then under my profile I selected Settings and then SSH and GPG keys from the menu on the left. Then New SSH key. I gave it a name, copied the key into the appropriate box (removed the trailing new-line) and finally clicked Add SSH Key.

I then switched to a Powershell tab in Terminal (in Windows 10 easier than trying to do it in Git Bash) where I used ssh-add to record the new key with ssh-agent.

Shot of Powershell tab where I used ssh-add to register new SSH key with ssh-agent

Now I am going to commit the changes I’ve made to this post today. And see if my push to GitHub goes smoothly.

That seemed to work. So going to repeat the process for Lynn’s GitHub account.

Add Lynn’s Key to GitHub Account and ssh-agent

Shot of Powershell tab where I used ssh-add to register Lynn's SSH key with ssh-agent

Setup Access to Lynn’s GitHub Repository

New Repository on Development PC

Now to test. I created a new blank repository in Lynn’s account on GitHub, lb_dbls. Will create said directory in my Hugo working directory. Initialize Git and add a .gitignore. And see if .gitignore will get pushed to GitHub.

PS R:\hugo> mkdir lb_dbls


    Directory: R:\hugo

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----

PS R:\hugo> cd lb_dbls
PS R:\hugo\lb_dbls> git init
Initialized empty Git repository in R:/hugo/lb_dbls/.git/
PS R:\hugo\lb_dbls> dir
PS R:\hugo\lb_dbls> ls
PS R:\hugo\lb_dbls> dir .*
PS R:\hugo\lb_dbls> git remote add origin git@github.com:Lynn###/lb_dbls.git
PS R:\hugo\lb_dbls> git add .gitignore
PS R:\hugo\lb_dbls> git cm "initial repository commit" -m "just .gitignore"
[master (root-commit) f47276f] initial repository commit
 1 file changed, 33 insertions(+)
 create mode 100644 .gitignore
PS R:\hugo\lb_dbls> git p
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

PS R:\hugo\lb_dbls> git push --set-upstream origin main
error: src refspec main does not match any
error: failed to push some refs to 'github.com:Lynn###/lb_dbls.git'
PS R:\hugo\lb_dbls> git branch -M main
PS R:\hugo\lb_dbls> git push --set-upstream origin main
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
PS R:\hugo\lb_dbls>

Let’s see who is being used to authenticate with GitHub

PS R:\hugo\lb_dbls> ssh -T git@github.com
Hi tooOld###! You've successfully authenticated, but GitHub does not provide shell access.
PS R:\hugo\lb_dbls> git remote -v
origin  git@github.com:Lynn###/lb_dbls.git (fetch)
origin  git@github.com:Lynn###/lb_dbls.git (push)
PS R:\hugo\lb_dbls>

Clearly the credentials for the tooOld### account should not be used. The answer appears to be to create an SSH config file with the information needed for each GitHub account. Then to set up Git in each repository to use them as appropriate. I didn’t have a config file, so created and then edited it. I created it in Powershell as a learning exercise.

PS C:\Users\bark\.ssh> New-Item -Name config -ItemType File

    Directory: C:\Users\bark\.ssh

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2023-10-03     09:25              0 config

PS C:\Users\bark\.ssh> dir

    Directory: C:\Users\bark\.ssh

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2023-10-03     09:25              0 config
-a----        2021-05-03     08:37           1679 ho###i
-a----        2021-05-03     08:37            393 ho###i.pub
-a----        2023-10-02     15:33            411 id_ed25519
-a----        2023-10-02     15:33            101 id_ed25519.pub
-a----        2018-02-01     13:04           3243 id_rsa_1
-a----        2018-02-01     13:04            745 id_rsa_1.pub
-a----        2023-04-04     16:07           5265 known_hosts
-a----        2020-11-27     11:41           4345 known_hosts - Copy
-a----        2023-10-02     15:24            411 lb_dbls
-a----        2023-10-02     15:24             96 lb_dbls.pub

PS C:\Users\bark\.ssh>

I then opened the file in VSCode and, based on an posting, added the following. I did not change the host for my remote repositories. Didn’t want to have to mess with possibility of needing to modify Git config for each of them. Hopefully this will continue to allow them to function as they currently do.

# TooOld### GitHub account
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519.pub

# Lynn's GitHub account
Host github-lb
  HostName github.com
  User git
  IdentityFile ~/.ssh/lb_dbls.pub
  LogLevel DEBUG3

I then went to the lb_dbls directory and removed the previous remote entry. And added the new one based on the host in the SSH config file.

PS R:\hugo\lb_dbls> git remote remove origin
PS R:\hugo\lb_dbls> git remote -v
PS R:\hugo\lb_dbls> git remote add origin git@github-lb:Lynn###/lb_dbls.git
PS R:\hugo\lb_dbls> git st
On branch main
nothing to commit, working tree clean
PS R:\hugo\lb_dbls> git p
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

So I tried that. Failed. In the rather verbose debug information printed in the terminal, I found Load key "/c/Users/bark/.ssh/lb_dbls.pub": invalid format. Some searching turned up a post that says the IdentityFile should be the private key, not the public one. As the former is what SSH has to use to authenticate with GitHub. Fixed that and:

PS R:\hugo\lb_dbls> git push --set-upstream origin main
debug2: resolving "github.com" port 22
debug2: ssh_connect_direct
debug1: Connecting to github.com [140.82.112.3] port 22.
debug1: Connection established.
debug1: identity file /c/Users/bark/.ssh/lb_dbls type 3
debug1: identity file /c/Users/bark/.ssh/lb_dbls-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3
debug1: Remote protocol version 2.0, remote software version babeld-dd067d10
debug1: no match: babeld-dd067d10
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to github.com:22 as 'git'
debug3: hostkeys_foreach: reading file "/c/Users/bark/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /c/Users/bark/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys from github.com
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256
debug2: host key algorithms: ssh-ed25519,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
debug2: MACs ctos: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256
debug2: MACs stoc: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:p2-----QM
debug3: hostkeys_foreach: reading file "/c/Users/bark/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /c/Users/bark/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys from github.com
debug3: hostkeys_foreach: reading file "/c/Users/bark/.ssh/known_hosts"
debug1: Host 'github.com' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/bark/.ssh/known_hosts:3
Warning: Permanently added the ECDSA host key for IP address '140.82.112.3' to the list of known hosts.
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/bark/.ssh/lb_dbls ED25519 SHA256:zJ------j8 explicit
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/bark/.ssh/lb_dbls ED25519 SHA256:zJ------j8 explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: /c/Users/bark/.ssh/lb_dbls ED25519 SHA256:zJ-----j8 explicit
debug3: sign_and_send_pubkey: ED25519 SHA256:zJ-----j8
debug3: sign_and_send_pubkey: signing using ssh-ed25519 SHA256:zJ-----j8
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([140.82.112.3]:22).
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x20
debug2: client_session2_setup: id 0
debug1: Sending command: git-receive-pack 'Lynn###/lb_dbls.git'
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 32000 rmax 35000
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: rcvd adjust 1248161
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 562 bytes | 187.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
debug2: channel 0: read<=0 rfd 4 len 0
debug2: channel 0: read failed
debug2: channel 0: chan_shutdown_read (i0 o0 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> drain
debug2: channel 0: send eof
debug3: send packet: type 96
debug2: channel 0: input drain -> closed
debug3: receive packet: type 98
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: channel 0: chan_shutdown_write (i3 o1 sock -1 wfd 5 efd 6 [write])
debug2: channel 0: output drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r43 i3/0 o3/0 e[write]/0 fd -1/-1/6 sock -1 cc -1)

debug3: send packet: type 1
debug3: fd 0 is not O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
Transferred: sent 3012, received 3000 bytes, in 0.9 seconds
Bytes per second: sent 3367.0, received 3353.5
debug1: Exit status 0
To github-lb:Lynn###/lb_dbls.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

I have left all the debug messages in the above listing in case anyone is interested in seeing a bit of the exchange between the Git and GitHub. The debug messages are actually from SSH and only show exchanges involving SSH interaction. Search for Authentication succeeded (publickey) and have a look at how much still happens afterwards.

Also after reading the above, I have decided to add another rule to each of the two hosts in the SSH config file. Specifically: PreferredAuthentications publickey,password. That should ensure the authentication using SSH public keys will be tried before any other methods. The default order is gssapi-with-mic,hostbased,publickey,keyboard-interactive,password . The two I have selected are likely the only ones I would use now and in future.

Test Push to Lynn’s GitHub Repo

So, I checked for changes to push to the remote.

PS R:\hugo\lb_dbls> git st
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

Because Git seemed to think there were no changes and everything was up to date with the remote repository, I modified .gitignore and tried again.

PS R:\hugo\lb_dbls> git st
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .gitignore

no changes added to commit (use "git add" and/or "git commit -a")
PS R:\hugo\lb_dbls> git add .
PS R:\hugo\lb_dbls> git cm "initial repository commit" -m "just .gitignore"
[main 7b2f6a1] initial repository commit
 1 file changed, 3 insertions(+)
PS R:\hugo\lb_dbls> git p
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 325 bytes | 162.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github-lb:Lynn###/lb_dbls.git
   f47276f..7b2f6a1  main -> main
Shot of code page Lynn's lb_dbls repo on GitHub

So far so good. Now to see if things still work for my personal account and the blogging repository.

Test Push to One of My Repos

I committed the edits I’d made to the file, then pushed to GitHub.

PS R:\hugo\tooOldCode> git cm "feat: add content covering setting up 2nd github account" -m "steps I took to make Lynn's repository available to me, quick test" -m "still need to test if access to my repositories still works"
[master a88e86b] feat: add cotent covering setting up 2nd github account
 2 files changed, 291 insertions(+), 3 deletions(-)
 create mode 100644 content/post/webdev/mutli_github/img/commit_lb_dbls._1.png
PS R:\hugo\tooOldCode> git p
Warning: Permanently added the ECDSA host key for IP address '140.82.112.4' to the list of known hosts.
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 16 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 19.82 KiB | 1.52 MiB/s, done.
Total 9 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To github.com:tooOld###/tooOld###
   24bf9cf..a88e86b  master -> master

And that seems to have worked as well.

Done

I do believe that is it for this one. Messy, lengthy and, for me, somewhat mind boggling.

Until next time, may your research and configuration efforts go much better than mine did these last few days.

Oh yes, have a typo in the post’s name, ‘mutli_’ rather than ‘multi_’. Have left it that way as ‘mutli’ was the way I felt while sorting this out.

Resources