-
Notifications
You must be signed in to change notification settings - Fork 10
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
Nested tmux session over ssh #1
Comments
I've thought about that, it should possible to notify an inner tmux session over SSH by sending a key (we send |
Hi there. One way to potentially support this is to use remote port fort forwarding in the # Tunnel client's localhost:8008 => remote-host's localhost:8008
ssh -R 8008:localhost:8008 remote-host OR more robustly in the ssh config Host remote-host
RemoteForward 8008 localhost:8008 On the remote host, we can redirect the On the client (local) machine, we can use There's a few caveats - A lot of enterprise/corporate servers are going to restrict what you can & can't do with ssh port forwarding (legitimate security reasons)- there's a decent chance you just can't for some servers. To enable portforwarding, the remote's AllowTcpForwarding yes To allow remote forwarding, it needs GatewayPorts yes |
Actually, according to Of course, a lot of enterprise servers run old versions of OpenSSH (My workplace's HPC runs OpenSSH 5.3), so we'll have to settle with using Since EDIT
nevermind, apparently it's valid to remote forward unix sockets. SO cool my gosh. |
This comment has been minimized.
This comment has been minimized.
I didn't know about forwarding UNIX sockets! Nice! Have you tried it? Does it work? |
This comment has been minimized.
This comment has been minimized.
Mmmh, why do you rename the remote socket? This does not support multiple nested sessions over the same machine. |
Good point, renamed because I'm not sure what we can write to, but I guess we can just forward the socket 1:1, meaning we can directly forward
I think so, I'm not sure about portability (requires I'll rewrite the script & hide the previous attempt |
RedundantHost remote-host
SendEnv TMUX
# Maybe wildcard? TMUX_* #!/usr/bin/env bash
# -R remote_socket:local_socket
ssh -R "${TMUX}:${TMUX}" -o SendEnv=TMUX remote-host |
|
Updated |
I actually haven't applied nested-tmux to my own tmux conf, btw, so I can't test this until I do so, if you're able to test it out I'd love to hear about it- Thank you for your feedback! If it works, I'd love to be the one to open the PR if that's okay |
Regarding directly forwarding the tmux socket, I just checked and it looks like my UID is encoded into the directory of the tmux socket, we may need to hack around that a bit for systems where the client uid != remote uid, idk |
Please, reduce the amount of messages, test things and then make a PR. |
Are there possibly any other ways to do this? I don't know about tmux's security model, but forwarding sockets leaves me a bit uncomfortable. - or is that unwarranted? |
Yeah, it'd be nice to limit what can be communicated back to the client only a signal to reactivate the outer layer. |
Ok so there are (at least?) two ways to do this
nested-tmux curently does the latter, which is what introduces the socket requirement. Looking through the tmux man page,
Items that caught my eye for tunneling information: If the clipboard hook combined with OSC 52 (apparently some sort of clipboard copy escape sequence; needs more research; example: https://gist.github.com/yudai/95b20e3da66df1b066531997f982b57b ) allows us to be notified on data transfer via the clipboard, we could parse arbitrary information. The main downside i see is having to deal with clobbering the clipboard, but apparently the xterm escape sequence (section P c ; P d section in https://www.xfree86.org/current/ctlseqs.html) can specify a target buffer? I'm not sure if that's the same thing though. tmux/tmux#1477 also looks very relevant to this approach. Anyway lot of this seems rather hacky and maybe it's worth asking the tmux developer for suggestions once there's a clear question. I don't immediately see any other hooks we could use. Another question is how to handle something with the ssh connection breaking, timing out, or accidentally outputting bad data on the terminal. This is generally a risk with in-band signaling. |
Making this work also would/could allow assimilating existing (nested) tmux sessions? |
Should we just try to get upstream to support nested tmux better by design? :P |
By upstream, do you mean nicm & the They're great maintainers, but they're pretty hard to influence, I guess you can try your luck lmao, but I'm sure this has already been raised with them |
FYI, my alternative plugin tmux-matryoshka supports nested tmux over ssh for free, without the need for the nested tmux session to be aware of the external one (though it might lack some of |
Hi, first of all, this is pretty sweet. One question I have is about nesting over ssh. In my client, I have tmux and I want to be able to ssh over to a server, run tmux and switch between the two. Is this something that is possible? I'm not very competent with tmux to know if we can even achieve this but it would be pretty cool if we can. If not, I can live with two terminals.
The text was updated successfully, but these errors were encountered: