48 lines
2.1 KiB
Markdown
48 lines
2.1 KiB
Markdown
# How to Automatically Start tmux on SSH Session (Codegenes)
|
|||
|
|
|
||
|
|
## Metadata
|
||
|
|
|
||
|
|
| Field | Value |
|
||
|
|
|---|---|
|
||
|
|
| Institute | Molodetz Institute — Research & Retrieval Division |
|
||
|
|
| Subject | shell-multiplexer-auto-attach |
|
||
|
|
| Document type | Source Dossier |
|
||
|
|
| Tier | 1 |
|
||
|
|
| Source title | How to automatically start tmux on SSH session |
|
||
|
|
| Source URL | https://www.codegenes.net/blog/how-to-automatically-start-tmux-on-ssh-session/ |
|
||
|
|
| Source publisher / author | Codegenes.net |
|
||
|
|
| Source type | blog post |
|
||
|
|
| Source date (published) | Unknown — not stated |
|
||
|
|
| Date researched | 2026-10-09 |
|
||
|
|
| Researched by | tai (agent), model: Claude Sonnet 5, on behalf of retoor |
|
||
|
|
| Research method | web search synthesis |
|
||
|
|
| Confidence | Medium |
|
||
|
|
| Status | Active |
|
||
|
|
|
||
|
|
## Summary
|
||
|
|
|
||
|
|
A fuller auto-attach recipe that combines two conditions: `[[ -n "$SSH_TTY" ]]` (only act when the session is an actual SSH login) and `[[ -z "$TMUX" ]]` (not already nested), rather than the bare `$TMUX` guard alone.
|
||
|
|
|
||
|
|
## Key findings
|
||
|
|
|
||
|
|
- `$SSH_TTY` is set specifically for an SSH login session with a pty, making it a useful qualifier for "only auto-attach over SSH logins," a narrower and safer scope than "every bash startup everywhere."
|
||
|
|
- Combining it with the `$TMUX` guard from the Arch forum dossier gives a two-condition gate rather than relying on one signal.
|
||
|
|
|
||
|
|
## Pros / strengths
|
||
|
|
|
||
|
|
- Narrows the blast radius of auto-attach logic specifically to a scenario (fresh SSH login) where multiplexing is genuinely almost always wanted, rather than firing on every local shell too.
|
||
|
|
|
||
|
|
## Cons / limitations / caveats
|
||
|
|
|
||
|
|
- Still vulnerable to the SSH-nesting failure mode described in this subject's unix.stackexchange dossier, since it doesn't address `$TMUX` failing to propagate across the SSH hop itself.
|
||
|
|
|
||
|
|
## Relevance to tai
|
||
|
|
|
||
|
|
A useful narrower variant for the proposal to consider: rather than auto-attaching on *every* interactive bash start, scope the riskiest/most valuable case (fresh remote logins) first, and treat local-terminal auto-attach as a separate, more cautious decision.
|
||
|
|
|
||
|
|
## Changelog
|
||
|
|
|
||
|
|
| Date | Change |
|
||
|
|
|---|---|
|
||
|
|
| 2026-10-09 | Initial dossier created. |
|