Skip to content
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

ProxyCommand breaks ssh integration #748

Open
OGKevin opened this issue Jun 20, 2024 · 1 comment
Open

ProxyCommand breaks ssh integration #748

OGKevin opened this issue Jun 20, 2024 · 1 comment

Comments

@OGKevin
Copy link

OGKevin commented Jun 20, 2024

It seems that the work done in #690 did not resolve an issue for me :(

❯ ps -t /dev/pts/0 -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
kevin                           1958670 1955432 -zsh
kevin                           2342684       1 /bin/bash /home/kevin/bin/scripts/iap-proxy.sh db-vm-*
kevin                           2342694 2342684 /home/kevin/.nix-profile/google-cloud-sdk/platform/bundledpythonunix/bin/python3 /home/kevin/.nix-profile/google-cloud-sd
kevin                           2350264 1958670 /bin/zsh /home/kevin/bin/scripts/gssh.sh dbtesting
kevin                           2350419 2350264 ssh db-vm-*
kevin                           2350463 2350419 /bin/bash /home/kevin/bin/scripts/iap-proxy.sh db-vm-*
kevin                           2350471 2350463 /home/kevin/.nix-profile/google-cloud-sdk/platform/bundledpythonunix/bin/python3 /home/kevin/.nix-profile/google-cloud-sd

❯ ps -t /dev/pts/7 -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
kevin                           2356162 1955432 -zsh
kevin                           2356728 2356162 /bin/zsh /home/kevin/bin/scripts/gssh.sh
kevin                           2356866 2356728 ssh -S /home/kevin/.ssh/*@db-vm-* db-vm-*

In my first pane, where the proxy is setup, the right hostname is not detected.
However since im using multiplexing, the next pane when I SSH again and re-use the session, the right hostname is detected.

I'm not sure whats the reason for it not to be detected in the first pane 🤔

Host db-vm-*
  User kevin_*
  ProxyCommand iap-proxy.sh %h
  ProxyUseFdpass no
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null

Host *
  ForwardAgent yes
  AddKeysToAgent no
  Compression no
  ServerAliveInterval 0
  ServerAliveCountMax 3
  HashKnownHosts yes
  UserKnownHostsFile ~/.ssh/known_hosts
  ControlMaster auto
  ControlPath ~/.ssh/%r@%n
  ControlPersist 1h

The * are just redactions.

@gpakosz
Copy link
Owner

gpakosz commented Aug 13, 2024

Hello @OGKevin 👋

Sorry for my late reply.
I'm not sure yet how to make #{hostname_ssh} and #{username_ssh} generally work when there's a ProxyCommand.

The logic detects the leaf process in a pane and when the leaf process is ssh, then try to get the remote username and hostname.

In your first example, it seems that the tree of processes is

-zsh
└── /bin/zsh /home/kevin/bin/scripts/gssh.sh dbtesting
    └── ssh db-vm-*
        └── /bin/bash /home/kevin/bin/scripts/iap-proxy.sh db-vm-*
            └── /home/kevin/.nix-profile/google-cloud-sdk/platform/bundledpythonunix/bin/python3 /home/kevin/.nix-profile/google-cloud-sd

The difficulty is to know where to break the chain...

If I'm not mistaken, iap-proxy.sh is a script you wrote yourself, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants