I'm attempting to link my Windows 11 PC to my Github account using ssh (as per this guide). I'm using cygwin in MobaXterm, and have successfully completed the process previously on a Windows 7 machine. The problem this time arises when trying to add the private-key using ssh-add; it produces the error
Could not add identity "/home/mobaxterm/.ssh/id_ed25519": agent refused operation
. I definitely have the agent running.
Previous questions have identified overly lax file permissions as a cause for this error. I have set the persistent home directory to a folder on my C drive, and in that directory given .ssh permissions 700 and the id_ed25519 file permissions 600 (and checked that they have been applied). However, ls -la /home/mobaxterm/.ssh
reveals id_ed25519 has permissions 644. I don't understand how the permissions can be different, as I assumed /home/mobaxterm is just a symbolic link: if I delete or add files in my directory, the changes are reflected in /home/mobaxterm. Running chmod directly on /home/mobaxterm has no effect.
I would be very grateful for help, as at present I can't push files to my GitHub!
You have two options to SSH with private keys using MobaXterm:
Pre-requisite
For both of the options you'll need to add your private keys in PPK format to PageAnt (installed with Putty) and specify you Use external Pageant
in MobaXterm SSH settings:
Refer to step 1 of this guide to learn how to add keys to PageAnt.
Note that PageAnt only accepts keys in PPK format, so you may need to convert your key pair to such format. You can do so with PuttyGen (refer to SO discussion here)
Option 1 - Local terminal
Start a local terminal and notice your current folder is /home/mobaxterm
.
Create a symbolic link to .ssh directory in your Windows profile folder:
ln -s /drives/c/Users/<YOUR_WINDOWS_USERNAME>/.ssh .ssh
Run ssh
including the path to your private key:
ssh -i ~/.ssh/<MY_PRIVATE_KEY> <REMOTE_USERNAME>@<REMOTE_SERVER>
Option 2 - SSH session
Create a new SSH session and configure the necessary parameters. Specifically, you must check Use private key
and point to the PPK file:
Additional hints: SSH config
Regarding operations against GitHub, you can include an entry in .ssh/config
like:
# GitHub for <USERNAME> account
Host github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/<PPK_PRIVATE_KEY>
This way you could run your git commands and the appropriate key would be automatically picked.