Wednesday, November 3, 2021

[SOLVED] Share ssh-agent - windows service, msys2 shell

Issue

Set-Up: Windows 10, Msys2 in ConEmu, fish shell

I want to run ssh-agent and share it between the shells, which isn't the problem per se. setting $SSH_AUTH_SOCK variable globally or even using an ~/.ssh/environment file would work.

However whatever shell I started first will be the owner of the ssh-agent process and close when I close that terminal window. At first I thought this was the answer: https://www.msys2.org/wiki/Setting-up-SSHd/ But sshd != ssh-agent .. dooh

So I was wondering if it would make sense and work if I used that script as a basis and made one to setup running ssh-agent as a cygrunsrv service.

I'm running into the problem, that ssh-agent sockets are owned by the uid which created it and can only be used by that uid and superuser.

Running msys2 with admin privileges doesn't seem to satisfy the "superuser" requirement.

Does this just simply not work? And if so, what's the alternative? I'm not really inclined to have one conemu shell open at all times and being careful not to close it.

Using one ssh-agent per shell is also not really something I enjoy considering, since I'd have to retype the password for my private keys every time.


Solution

nohup should solve the original problem by detaching the ssh-agent process from its terminal.



Answered By - David Macek