masahide / OmniSSHAgent

Integrated ssh-agent for windows. (pageant compatible. openSSH ssh-agent etc ..)
Apache License 2.0
127 stars 9 forks source link

Named pipe stops working after a while the system is on #20

Open maicol07 opened 2 years ago

maicol07 commented 2 years ago

It seems that named pipe stops working after a while the system is on:

PS C:\Users\Maicol> ssh-add -l
Error connecting to agent: No such file or directory
PS C:\Users\Maicol> Get-ChildItem \\.\pipe\|findstr open
------        01/01/1601     01:00              1 openssh-ssh-agent

WSL:

  ~ ❯ ssh-add -l                                                                                              19:43:23
error fetching identities: communication with agent failed

However, Git bash works:

$ ssh-add -l
3072 SHA256:xInBcA48YT6jmmOEWQrXtC+xw+c6V2V2cVgAWT6K9hg id_rsa (RSA)
256 SHA256:ZgvmgA5CNIpEbTZWepclAdXC9fVBFsB1kvmM14Egjm8 id_ed25519 (ED25519)

I've currently tested the named pipe mode and the 1password proxy mode and the two modes are affected. Do you have any clue? Thanks

masahide commented 2 years ago

There may be something wrong with the omni-socat process. When does this occur? Does it always result in an error?

Create a debug log output mode to check the status.

masahide commented 2 years ago

Please ps the socat process startup in WSL.

$ ps axuw|grep socat
masahide 14784  0.0  0.0   6968  1788 ?        Ss   13:43   0:00 socat UNIX-LISTEN:/home/masahide/.ssh/agent.sock,fork EXEC:/home/masahide/omni-socat/omni-socat.exe,nofork
masahide commented 2 years ago

https://github.com/masahide/OmniSSHAgent/releases/tag/0.3.1

Added debug log output mode to omni-socat. Debug mode is enabled by doing the following. Logs are output to /mnt/c/User//omni-socat.log.

In WSL console, do the following

# kill socat prosess
killall socat 
# remove old omni-socat.exe
rm ~/omni-socat/omni-socat.exe

Rewrite ~/omni-socat/ubuntu-bash.setup.sh

(setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$OMNISOCATCMD",nofork &) >/dev/null 2>&1

to

(setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$OMNISOCATCMD -debug",nofork &) >/dev/null 2>&1

Restart WSL console.

# Try ssh-agent communication
ssh-add -l
# cat logfile
cat  /mnt/c/User/<user_name>/omni-socat.log
2022/05/27 21:24:19 npipe2stdin.go:44: Started omni-socat
2022/05/27 21:24:19 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/27 21:24:19 npipe2stdin.go:58: Disconnected. [<nil>]
maicol07 commented 2 years ago

When does this occur?

There isn't a specific time when this occurs

Does it always result in an error?

Yes, the error of the OP

Please ps the socat process startup in WSL.

This after updating to 0.3.1:

~ ❯ ps axuw|grep socat  12s 15:44:40
maicol07 3558 0.0 0.0 10280 2952 ? Ss 15:10 0:00 socat UNIX-LISTEN:/home/maicol07/.ssh/agent.sock,fork E
XEC:/home/maicol07/omni-socat/omni-socat.exe -debug
maicol07 4837 0.0 0.0 6476 2272 pts/0 S+ 15:44 0:00 grep --color=auto socat

After update the result is:

~ ❯ ssh-add -l                                                                                              15:44:42
error fetching identities: communication with agent failed
~ ❯ cat /mnt/c/Users/Maicol/omni-socat.log                                                                  15:46:17
cat: /mnt/c/Users/Maicol/omni-socat.log: No such file or directory
masahide commented 2 years ago

It seems that /usr/bin/socat and $HOME/omni-socat/omni-socat.exe are not communicating.

Check $SSH_AUTH_SOCK

$ echo $SSH_AUTH_SOCK
/home/masahide/.ssh/agent.sock

Check if omni-socat.exe is executable from WSL.

$ ~/omni-socat/omni-socat.exe -h
Usage of omni-socat.exe:
  -debug
        Output debug log

Manually start socat and check operation

# Kill already activated socat
killall socat
# Start socat
socat UNIX-LISTEN:$HOME/.ssh/agent.sock,fork EXEC:"$HOME/omni-socat/omni-socat.exe -debug"

Start another console to check.

masahide@DESKTOP-BI62AKS:~$ ls -la $SSH_AUTH_SOCK
srwxr-xr-x 1 masahide masahide 0 May 28 16:16 /home/masahide/.ssh/agent.sock
masahide@DESKTOP-BI62AKS:~$ ssh-add -l
maicol07 commented 2 years ago

First console:

~ ❯ ssh-add -l                                                                                              09:20:12
error fetching identities: communication with agent failed
~ ❯ echo $SSH_AUTH_SOCK                                                                                     09:20:23
/home/maicol07/.ssh/agent.sock
~ ❯ ~/omni-socat/omni-socat.exe -h                                                                          09:20:29
fish: The file '/home/maicol07/omni-socat/omni-socat.exe' is not executable by this user
~ ❯ killall socat                                                                                     ✘ 126 09:20:42
~ ❯ socat UNIX-LISTEN:$HOME/.ssh/agent.sock,fork EXEC:"$HOME/omni-socat/omni-socat.exe -debug"              09:21:07
2022/05/28 09:21:12 socat[855] E "/home/maicol07/.ssh/agent.sock" exists

Second console:

~ ❯ ls -la $SSH_AUTH_SOCK                                                                                   09:21:25
srwxr-xr-x 1 maicol07 maicol07 0 mag 28 09:21 /home/maicol07/.ssh/agent.sock=
~ ❯ ssh-add -l                                                                                              09:21:28
error fetching identities: communication with agent failed
masahide commented 2 years ago

fish: The file '/home/maicol07/omni-socat/omni-socat.exe' is not executable by this user

Perhaps you do not have execute permissions?

Check the permissions on ~/omni-socat/omni-socat.exe

> ls -la ~/omni-socat/omni-socat.exe
-rwxrwxrwx 1 masahide masahide 3675648 May 27 21:16 /home/masahide/omni-socat/omni-socat.exe*
maicol07 commented 2 years ago
~ ❯ ls -la ~/omni-socat/omni-socat.exe                                                                      11:46:55
-rw-r--r-- 1 maicol07 maicol07 3675648 mag 27 21:16 /home/maicol07/omni-socat/omni-socat.exe

Let me try to chmod it

maicol07 commented 2 years ago

Chmodded. Now I get:

masahide commented 2 years ago

I wonder why... It looks like the file is corrupt. There may be a problem with the download script. In the meantime, let's get the file directly with curl and check it out!

$ curl https://github.com/masahide/OmniSSHAgent/releases/latest/download/omni-socat.zip -sLo omni-socat.zip
$ unzip omni-socat.zip
Archive:  omni-socat.zip
  inflating: omni-socat.exe
$ sha1sum  omni-socat.exe
d34e4797eaa493b301356d361a8d5473913b41fb  omni-socat.exe
$ ls -la  omni-socat.exe
-rwxrwxrwx 1 masahide masahide 3675648 May 27 21:16 omni-socat.exe
$ ./omni-socat.exe -h
Usage of omni-socat.exe:
  -debug
        Output debug log
$ uname -a
Linux DESKTOP-BI62AKS 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
maicol07 commented 2 years ago
~ ❯ ssh-add -l                                                                                              11:49:18
error fetching identities: communication with agent failed
~ ❯ cd omni-socat/                                                                                  1m 51s 11:51:13
~/omni-socat ❯ curl https://github.com/masahide/OmniSSHAgent/releases/latest/download/omni-socat.zip -sLo omni-socat
.zip
~/omni-socat ❯ unzip omni-socat.zip                                                                         12:26:02
Archive:  omni-socat.zip
replace omni-socat.exe? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
  inflating: omni-socat.exe
~/omni-socat ❯ sha1sum omni-socat.exe                                                                   4s 12:26:17
d34e4797eaa493b301356d361a8d5473913b41fb  omni-socat.exe
~/omni-socat ❯ ls -la omni-socat.exe                                                                        12:26:30
-rwxrwxrwx 1 maicol07 maicol07 3675648 mag 27 14:16 omni-socat.exe*
~/omni-socat ❯ ./omni-socat.exe -h                                                                          12:26:44
Usage of omni-socat.exe:
  -debug
        Output debug log
~/omni-socat ❯ uname -a                                                                                     12:26:52
Linux MAICOL-ROG 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
~/omni-socat ❯ ssh-add -l                                                                                   12:27:02
error fetching identities: communication with agent failed
~/omni-socat ❯ killall socat                                                                                12:27:28
~/omni-socat ❯ socat UNIX-LISTEN:$HOME/.ssh/agent.sock,fork EXEC:"$HOME/omni-socat/omni-socat.exe -debug"   12:27:37
2022/05/28 12:27:44 socat[3705] E "/home/maicol07/.ssh/agent.sock" exists

~/omni-socat ❯ ssh-add -l                                                                                   12:28:00
3072 SHA256:xInBcA48YT6jmmOEWQrXtC+xw+c6V2V2cVgAWT6K9hg id_rsa (RSA)
256 SHA256:ZgvmgA5CNIpEbTZWepclAdXC9fVBFsB1kvmM14Egjm8 id_ed25519 (ED25519)

I don't know redownloading helped, I'll let you know in some days if I get the error again.

ddrown commented 2 years ago

I think I'm seeing the same issue: image

What's strange is it runs outside of socat:

$ curl https://github.com/masahide/OmniSSHAgent/releases/latest/download/omni-socat.zip -sLo omni-socat.zip
$ unzip omni-socat.zip
Archive:  omni-socat.zip
  inflating: omni-socat.exe
$ ls -l
total 5612
-rwxrwxrwx 1 ddrown ddrown 3675648 May 27 07:16 omni-socat.exe
-rw-rw-r-- 1 ddrown ddrown 2067854 May 31 10:17 omni-socat.zip
$ sha1sum omni-socat.exe
d34e4797eaa493b301356d361a8d5473913b41fb  omni-socat.exe
$ ./omni-socat.exe -h
Usage of omni-socat.exe:
  -debug
        Output debug log
$ socat UNIX-LISTEN:/home/ddrown/.ssh/agent.sock,fork EXEC:"./omni-socat.exe -debug" &
$ ssh-add -l
error fetching identities: communication with agent failed
ddrown commented 2 years ago

It was working on Friday (May 27) but broke between then and today (May 31).

I tried:

None of those worked

Rebooted my laptop, and it's back to working again 🤷

masahide commented 2 years ago

Thank you for your report. It seems that there is some kind of problem with the linkage between socat and omni-socat. However, I think the internal implementation of npiperelay is almost the same, so if npiperelay doesn't work either, there may be a problem elsewhere. I will also investigate.(I haven't been able to reproduce the problem yet, but from there...)

maicol07 commented 2 years ago

@masahide got this again and nothing has been logged

~ ❯ ssh-add -l                                                                                              23:45:45
error fetching identities: communication with agent failed
~ ❯ cat /mnt/c/Users/Maicol/omni-socat.log                                                                  23:45:47
2022/05/28 12:27:59 npipe2stdin.go:44: Started omni-socat
2022/05/28 12:27:59 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 12:27:59 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/28 12:28:03 npipe2stdin.go:44: Started omni-socat
2022/05/28 12:28:03 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 12:28:03 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/28 12:29:14 npipe2stdin.go:44: Started omni-socat
2022/05/28 12:29:14 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 12:29:14 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/28 12:29:44 npipe2stdin.go:44: Started omni-socat
2022/05/28 12:29:44 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 12:29:44 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/28 20:53:24 npipe2stdin.go:44: Started omni-socat
2022/05/28 20:53:24 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 20:53:28 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/29 01:45:16 npipe2stdin.go:44: Started omni-socat
2022/05/29 01:45:16 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/29 01:45:16 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/29 01:45:19 npipe2stdin.go:44: Started omni-socat
2022/05/29 01:45:19 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/29 01:45:19 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/29 16:28:28 npipe2stdin.go:44: Started omni-socat
2022/05/29 16:28:28 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/29 16:28:33 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/31 12:45:21 npipe2stdin.go:44: Started omni-socat
2022/05/31 12:45:21 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/31 12:45:27 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/31 15:36:39 npipe2stdin.go:44: Started omni-socat
2022/05/31 15:36:39 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/31 15:36:39 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 01:27:35 npipe2stdin.go:44: Started omni-socat
2022/06/01 01:27:35 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 01:27:40 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 13:25:59 npipe2stdin.go:44: Started omni-socat
2022/06/01 13:25:59 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 13:26:03 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 13:45:46 npipe2stdin.go:44: Started omni-socat
2022/06/01 13:45:46 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 13:45:49 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 14:42:04 npipe2stdin.go:44: Started omni-socat
2022/06/01 14:42:04 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 14:42:10 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 14:56:12 npipe2stdin.go:44: Started omni-socat
2022/06/01 14:56:12 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 14:56:12 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 15:10:22 npipe2stdin.go:44: Started omni-socat
2022/06/01 15:10:22 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 15:10:22 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 15:20:15 npipe2stdin.go:44: Started omni-socat
2022/06/01 15:20:15 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 15:20:15 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 15:27:34 npipe2stdin.go:44: Started omni-socat
2022/06/01 15:27:34 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 15:27:34 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 15:40:48 npipe2stdin.go:44: Started omni-socat
2022/06/01 15:40:48 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 15:40:48 npipe2stdin.go:58: Disconnected. [<nil>]
~ ❯ ps axuw|grep socat                                                                                      23:45:51
maicol07   484  0.0  0.0  10276  3008 ?        Ss   15:54   0:00 socat UNIX-LISTEN:/home/maicol07/.ssh/agent.sock,fork EXEC:/home/maicol07/omni-socat/omni-socat.exe -debug
maicol07 11729  0.0  0.0   6476  2248 pts/2    S+   23:46   0:00 grep --color=auto socat
masahide commented 2 years ago

Thank you very much.

Do you get help by running /home/maicol07/omni-socat/omni-socat.exe -h? Also sha1sum /home/maicol07/omni-socat/omni-socat.exe and ls -la $SSH_AUTH_SOCK please.

maicol07 commented 2 years ago

Rebooted and works... next time!

maicol07 commented 2 years ago

@masahide new case:

  ~ ❯ ssh-add -l                                                                                              17:41:18
error fetching identities: communication with agent failed
  ~ ❯ cat /mnt/c/Users/Maicol/omni-socat.log                                                                  22:10:52
2022/05/28 12:27:59 npipe2stdin.go:44: Started omni-socat
2022/05/28 12:27:59 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 12:27:59 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/28 12:28:03 npipe2stdin.go:44: Started omni-socat
2022/05/28 12:28:03 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 12:28:03 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/28 12:29:14 npipe2stdin.go:44: Started omni-socat
2022/05/28 12:29:14 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 12:29:14 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/28 12:29:44 npipe2stdin.go:44: Started omni-socat
2022/05/28 12:29:44 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 12:29:44 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/28 20:53:24 npipe2stdin.go:44: Started omni-socat
2022/05/28 20:53:24 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/28 20:53:28 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/29 01:45:16 npipe2stdin.go:44: Started omni-socat
2022/05/29 01:45:16 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/29 01:45:16 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/29 01:45:19 npipe2stdin.go:44: Started omni-socat
2022/05/29 01:45:19 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/29 01:45:19 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/29 16:28:28 npipe2stdin.go:44: Started omni-socat
2022/05/29 16:28:28 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/29 16:28:33 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/31 12:45:21 npipe2stdin.go:44: Started omni-socat
2022/05/31 12:45:21 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/31 12:45:27 npipe2stdin.go:58: Disconnected. [<nil>]
2022/05/31 15:36:39 npipe2stdin.go:44: Started omni-socat
2022/05/31 15:36:39 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/05/31 15:36:39 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 01:27:35 npipe2stdin.go:44: Started omni-socat
2022/06/01 01:27:35 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 01:27:40 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 13:25:59 npipe2stdin.go:44: Started omni-socat
2022/06/01 13:25:59 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 13:26:03 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 13:45:46 npipe2stdin.go:44: Started omni-socat
2022/06/01 13:45:46 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 13:45:49 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 14:42:04 npipe2stdin.go:44: Started omni-socat
2022/06/01 14:42:04 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 14:42:10 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 14:56:12 npipe2stdin.go:44: Started omni-socat
2022/06/01 14:56:12 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 14:56:12 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 15:10:22 npipe2stdin.go:44: Started omni-socat
2022/06/01 15:10:22 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 15:10:22 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 15:20:15 npipe2stdin.go:44: Started omni-socat
2022/06/01 15:20:15 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 15:20:15 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 15:27:34 npipe2stdin.go:44: Started omni-socat
2022/06/01 15:27:34 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 15:27:34 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/01 15:40:48 npipe2stdin.go:44: Started omni-socat
2022/06/01 15:40:48 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/01 15:40:48 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/03 09:00:37 npipe2stdin.go:44: Started omni-socat
2022/06/03 09:00:37 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/03 09:00:37 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/03 09:01:08 npipe2stdin.go:44: Started omni-socat
2022/06/03 09:01:08 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/03 09:01:08 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/03 09:01:22 npipe2stdin.go:44: Started omni-socat
2022/06/03 09:01:22 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/03 09:01:24 npipe2stdin.go:58: Disconnected. [<nil>]
2022/06/03 15:16:45 npipe2stdin.go:44: Started omni-socat
2022/06/03 15:16:45 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/03 15:16:48 npipe2stdin.go:58: Disconnected. [<nil>]
  ~ ❯ ps axuw|grep socat                                                                                      22:12:16
maicol07   497  0.0  0.0  10276  2964 ?        Ss   10:29   0:00 socat UNIX-LISTEN:/home/maicol07/.ssh/agent.sock,fork EXEC:/home/maicol07/omni-socat/omni-socat.exe -debug
maicol07  2972  0.0  0.0   6476  2328 pts/1    S+   22:12   0:00 grep --color=auto socat
  ~ ❯ /home/maicol07/omni-socat/omni-socat.exe -h                                                             22:12:36
Usage of omni-socat.exe:
  -debug
        Output debug log
  ~ ❯ sha1sum /home/maicol07/omni-socat/omni-socat.exe                                                        22:12:46
d34e4797eaa493b301356d361a8d5473913b41fb  /home/maicol07/omni-socat/omni-socat.exe
  ~ ❯ ls -la $SSH_AUTH_SOCK                                                                                   22:13:01
srwxr-xr-x 1 maicol07 maicol07 0 giu  6 10:29 /home/maicol07/.ssh/agent.sock=
masahide commented 2 years ago

Thanks. From the information you gave us, it looks like the omni-socat.exe is fine and the socat process is causing the problem.

It may be a problem with the combination of socat and WSL2. https://github.com/microsoft/WSL/issues/7560

I'll look into it some more, but if there's nothing I can do about it. I think I can solve this problem by creating something like socat myself. Please give me some time.

maicol07 commented 2 years ago

New issue today, but I don't know if it's related:

sign_and_send_pubkey: signing failed for RSA "/home/maicol07/.ssh/id_rsa" from agent: agent refused operation
sign_and_send_pubkey: signing failed for ED25519 "id_ed25519" from agent: agent refused operation
maicol07@192.168.1.111: Permission denied (publickey)

Log:

2022/06/10 16:16:59 npipe2stdin.go:44: Started omni-socat
2022/06/10 16:16:59 npipe2stdin.go:51: Opened pipe:[\\.\pipe\openssh-ssh-agent]
2022/06/10 16:16:59 npipe2stdin.go:58: Disconnected. [<nil>]
maicol07 commented 2 years ago

Useful detail (maybe): restarting 1password when this happens fixes the issue

masahide commented 2 years ago

Useful detail (maybe): restarting 1password when this happens fixes the issue

When 1password was restarted, did socat recover without KILL?

maicol07 commented 2 years ago

Yes, I only restart 1Password. Other things and services are untouched

masahide commented 2 years ago

It may be a glitch on 1password's part. If you get the error again, could you try ssh-add.exe in windows.

Could you try ssh-add -L?

C:\Windows\System32\OpenSSH\ssh-add.exe -L
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIChI8AXMLP3pp1/9++H9Ebh3BiqMGJMIhc5f4Pxtk+By id_ed25519 masahide 20220322

If you get a key list error with ssh-add.exe, it may be a bug on 1password's side.

maicol07 commented 2 years ago

@masahide windows ssh-add never worked for me (in the PC I'm currrently using. On another PC works):

PS C:\Users\Maicol> ssh-add -L
Error connecting to agent: No such file or directory
PS C:\Users\Maicol> ssh-add.exe -L
Error connecting to agent: No such file or directory

I'm not sure whether restarting 1Password fixes the original test (I will try that when I get it), but it fixes this one: https://github.com/masahide/OmniSSHAgent/issues/20#issuecomment-1152414315

masahide commented 2 years ago

If C:\WindowsSystem32\OpenSSH\ssh-add.exe outputs "Error connecting to agent: No such file or directory", the 1password ssh agent is not functioning properly.

https://developer.1password.com/docs/ssh/agent

maicol07 commented 2 years ago

I've debugged a bit and it seems Omni overwrites the pipe used by Microsoft OpenSSH:

 Maicol    ~  ﮫ0ms⠀   ssh-add.exe -L                                            pwsh   100  09:24:29 
Error connecting to agent: No such file or directory
 Maicol    ~  ﮫ39ms⠀   echo $env:SSH_AUTH_SOCK                                  pwsh   100  09:24:34 
/c/Users/Maicol/OmniSSHCygwin.sock
 Maicol    ~  ﮫ18ms⠀   $env:SSH_AUTH_SOCK = '\\.\pipe\openssh-ssh-agent'        pwsh   100  09:24:40 
 Maicol    ~  ﮫ2ms⠀   echo $env:SSH_AUTH_SOCK                                   pwsh   100  09:24:44 
\\.\pipe\openssh-ssh-agent
 Maicol    ~  ﮫ30ms⠀   ssh-add.exe -l                                           pwsh   100  09:24:48 
3072 SHA256:xInBcA48YT6jmmOEWQrXtC+xw+c6V2V2cVgAWT6K9hg id_rsa (RSA)
256 SHA256:ZgvmgA5CNIpEbTZWepclAdXC9fVBFsB1kvmM14Egjm8 id_ed25519 (ED25519)

I've checked in env variables and there was a manually added SSH_AUTH_SOCK variable that was causing this issue.

I'll keep you updated if I have the previous issues

masahide commented 2 years ago

Sorry, I'm sorry, I'm not sure if you are using Cygwin/MSYS2/Git for windows. In that case, ssh-add.exe may not work because you have rewritten the environment variable "SSH_AUTH_SOCK" as you indicated.

maicol07 commented 2 years ago

No, I'm not using Cygwin and the others.

I'm only using WSL2 and rarely Powershell

ddrown commented 1 year ago

I've been using this every day since I added my comments, and it's been stable ever since then. I guess something changed, but I don't know what.

masahide commented 1 year ago

Thank you for the information. However, the cause of this particular problem is still unknown and no particular measures have been taken. Maybe there is some underlying timing or combination problem. I will continue to wait for the report.