To use two GitHub accounts on a Mac over ssh, you will need to set up separate ssh keys for each account.
Follow the steps below:
Generate a new ssh key for your second GitHub account. You can do this by running the ssh-keygen command in the terminal and following the prompts. Make sure to specify a different file name for the key than the one you used for your first account.
Add the public key for your second account to your GitHub account. You can do this by going to the "SSH and GPG keys" section of your GitHub profile settings and clicking the "New SSH key" button. Then, paste the contents of the public key file (located in the ~/.ssh directory on your Mac) into the "Key" field and give it a descriptive name.
Add the private key for your second account to your ssh agent. You can do this by running the following command in the terminal:
username@hostname:~$ssh-add ~/.ssh/<private key file name>
Modify your ssh config file to specify which ssh key to use for each GitHub account. To do this, open the ~/.ssh/config file in a text editor and add the following lines: