-
-
Notifications
You must be signed in to change notification settings - Fork 805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSH agent forwarding doesn't work with unix_domains
#1647
Comments
Try this on the remote host: mux_env_remove = {
-- "SSH_AUTH_SOCK", -- remove this line
"SSH_CLIENT",
"SSH_CONNECTION",
} |
Just tried that, it didn't make any difference - which is probably something to do with the fact that, like When I connect through |
OK, so what's happening here is:
This issue is not specific to wezterm; it applies also to screen and tmux. This gist: https://gist.github.com/martijnvermaat/8070533 has some suggestions on how to manage this sort of thing cooperatively between your shell and ssh configuration on the remote host. |
I'm using this on tmux and it works fine. I basically run |
Anyway, this seems to work for me: ~/.zshrc if [ -n "$SSH_CONNECTION" ]; then
export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
fi ~/.ssh/rc #!/bin/bash
if test "$SSH_AUTH_SOCK" ; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
fi |
Just thinking out loud. https://www.libssh2.org/examples/ssh2_agent_forwarding.html has an example of setting up the agent forwarding channel. |
+1. Even with a plain unix domain (no |
I don't think this helps with the multiplexer scenario, but I want to note that #5345 enables agent forwarding in wezterms internal ssh implementation in |
This is done with a wezterm twist: not only is the auth sock forwarded, but the mux on the remote end will automatically maintain a symlink to point to the auth sock of the most recently active mux client, and set SSH_AUTH_SOCK to that symlink so that your remote panes should always be referencing something sane. refs: #1647 refs: #988
as of 4af418f, the mux server now automatically maintains SSH_AUTH_SOCK based on the most recently active multiplexer client. |
This is wonderful, thanks a ton!!! I can confirm my session is correctly forwarded when doing |
This is done with a wezterm twist: not only is the auth sock forwarded, but the mux on the remote end will automatically maintain a symlink to point to the auth sock of the most recently active mux client, and set SSH_AUTH_SOCK to that symlink so that your remote panes should always be referencing something sane. refs: wez#1647 refs: wez#988
What Operating System(s) are you seeing this problem on?
Linux X11, macOS
WezTerm version
20220101-133340-7edc5b5a
Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?
No, and I'll explain why below
Describe the bug
I tried to use the information in #1568 to connect to a remote
wezterm-mux-server
in an attempt to get SSH agent forwarding working in a wezterm unix domain. While agent forwarding works through a normalssh -A hostname
command, when usingwezterm connect hostname
, it doesn't - even though a socket is created on the remote host like it is withssh -A
,$SSH_AUTH_SOCK
is not set. Manually runningexport SSH_AUTH_SOCK=/path/to/socket
gets agent forwarding working, but this is not a solution long-term.This issue is a continuation of my comments on #1568.
To Reproduce
I have wezterm
20220101-133340-7edc5b5a
installed onrigel
, which is the client machine running macOS 12.0.1 (21A559) and configured throughnix-darwin
. The remote host,talitha
, is a NixOS 21.11.20220210.7adc9c1 (Porcupine) machine also running wezterm20220101-133340-7edc5b5a
.The client is running
ssh-agent
from OpenSSH 8.8p1, and the agent has aned25519-sk
key loaded, which is resident on a Yubikey. First, to test that SSH agent forwarding is working correctly when usingssh
normally, I can runssh -A talitha
. This causes the Yubikey to flash, prompting me to touch it, at which point the SSH connection succeeds. Then runningssh -T [email protected]
ontalitha
through the SSH connection also causes the Yubikey to flash, and when I touch it, the connection succeeds. Runningecho $SSH_AUTH_SOCK
ontalitha
reports, e.g./tmp/ssh-XXXXjYEJ5n/agent.235345
(this changes on each new connection), andssh-add -L
reports the correct key is available.Then I added the
unix_domains
section I've provided below to my~/.config/wezterm/wezterm.lua
(from #1568) and reloaded my configuration.wezterm connect talitha
does the following things:When I touch the Yubikey, it then:
talitha
, opening a prompt in the new windowNow, running
ssh -T [email protected]
ontalitha
through the SSH connection does not cause the Yubikey to flash and immediately prints the following:Running
echo $SSH_AUTH_SOCK
ontalitha
produces an empty output, andssh-add -L
prints:If I then run
echo /tmp/ssh*/*
to determine the location of the forwarded SSH socket, and then manually set$SSH_AUTH_SOCK
:...then
ssh -T [email protected]
succeeds (causes the Yubikey to flash, and connects successfully after I touch it), andssh-add -L
correctly reports the key is available.Configuration
On the client (
rigel
), this is relevant section of my config:Expected Behavior
I expect
wezterm connect talitha
to open a new Wezterm window containing a prompt that behaves the same way as the one I get when I runssh -A talitha
- I should be able to perform SSH operations using the ssh-agent running on my local machine.Logs
CTRL-SHIFT-L doesn't open anything on my macOS machine, it just seems to send CTRL-L to the terminal, clearing it.
Anything else?
I haven't tried the latest nightly build to see if it helps, because it's a bit of a pain - for me, that involves having to write a Nix overlay - but I'm happy to do that a little later today if you think it'd be a good idea.
I've tried adding this to
rigel
's~/.ssh/config
:...and this to
talitha
's~/.config/wezterm/wezterm.lua
:...but neither made a difference.
The text was updated successfully, but these errors were encountered: