gpakosz / .tmux

🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
MIT License
21.54k stars 3.33k forks source link

SSH Hostname Not Displayed Correctly on Status Right/Left #718

Closed kitos9112 closed 5 months ago

kitos9112 commented 5 months ago

Hello!

I've been going through a few older issues #361 #690

Put simply, I just want to display the full SSH hostname on my status bar.

To simplify troubleshooting I've just set tmux_conf_theme_status_right=" #{hostname_full_ssh} " in ~/.tmux.conf.local

With only 2 panes. I replicated the debug steps stated on https://github.com/gpakosz/.tmux/issues/627#issuecomment-1440661476

In pane 2: Run $ tmux display -p '#{pane_pid} #{pane_tty}'

102938 `/dev/pts/2

Then ssh to a remote host

ssh myremotessh-host.company.net

In pane 1: Run ps -t /dev/ttysYYY -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= And paste the result here

❯  ps -t /dev/pts/2 -o user=myuser -o pid= -o ppid= -o command=
myuser
myuser  102938   98286 -zsh
myuser  103415   12323 -zsh
myuser  103465   12323 -zsh
myuser  103467   12323 -zsh
myuser  103468  103415 /home/myuser/.cache/gitstatus/gitstatusd-linux-x86_64 -G v1.5.4 -s -1 -u -1 -d -
myuser 3163296  102938 ssh myremotessh-host.company.net
myuser 3163299 3163296 /usr/bin/sss_ssh_knownhostsproxy -p 22 myremotessh-host.company.net

In Pane 1: Run cut -c3- ~/.tmux.conf | sh -sx _pane_info XXXX /dev/ttysYYY

❯ cut -c3- ~/.tmux.conf | sh -sx _pane_info 102938 /dev/pts/2
+ :
+ set -e
+ unset GREP_OPTIONS
+ export LC_NUMERIC=C
+ set +H
+ printf
+ sed -E s///
+ uname -s
+ _uname_s=Linux
+ [ -z /tmp/tmux-155554/default,98286,0 ]
+ [ -z /tmp/tmux-155554/default ]
+ [ -z /usr/bin/tmux ]
+ [ /usr/bin/tmux = tmux ]
+ tmux -V
+ /usr/bin/tmux -S /tmp/tmux-155554/default -V
+ awk {gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}
+ _tmux_version=320
+ command -v pkill
+ _pane_info 102938 /dev/pts/2
+ pane_pid=102938
+ pane_tty=pts/2
+ ps -t pts/2 --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command=
+ awk -v pane_pid=102938
        ((/ssh/ && !/-W/ && !/tsh proxy ssh/) || !/ssh/) && !/tee/ {
          user[$2] = $1; if (!child[$3]) child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = substr($0,4)
        }
        END {
          pid = pane_pid
          while (child[pid])
            pid = child[pid]

          print pid":"user[pid]":"command[pid]
        }

102938:myuser:-zsh
gpakosz commented 5 months ago

Hello @kitos9112,

Can you please share your ~/.ssh/config file? Redact as necessary.

kitos9112 commented 5 months ago

Hello @gpakosz 👋🏼!

Yup, here it comes the SSH config that matches the target host

Host *.company.net
    User myUser
    GSSAPIDelegateCredentials yes
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
kitos9112 commented 5 months ago

I must add to the above comment that we also add a few custom lines from /etc/ssh/ssh_config

PubkeyAuthentication yes
GlobalKnownHostsFile /var/lib/sss/pubconf/known_hosts
Match exec true
  ProxyCommand /usr/bin/sss_ssh_knownhostsproxy -p %p %h
gpakosz commented 5 months ago

Ah yeah I'm not sure I can make all the ssh introspection work with custom ProxyCommand directives 🤔

gpakosz commented 5 months ago

I'll give it a try but I can't promise an ETA

gpakosz commented 5 months ago

Hmm actually it might be as simple as dealing with #690

Can you please give the gh-718 branch a try?

kitos9112 commented 5 months ago

On it. Yup

kitos9112 commented 5 months ago

Oh, amazing. It does work!

Any ETA to get those lines rebased into master?

gpakosz commented 5 months ago

Merged 🏎️