3 ms·
SSH straight into tmux Host example.org RemoteCommand tmux new -A -s default Instead of this, i go one step further, and in .zshrc on username@example.org:
by hprotagonist 4y ago
SSH straight into tmux
Host example.org
RemoteCommand tmux new -A -s default
Instead of this, i go one step further, and in .zshrc on username@example.org:
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
[ -z "${TMUX}" ] && tmux new-session -A -s default
fi
- mattrighetti 4y agoI’m using the .zshrc trick too, what are the pros and cons of both? I would like to try out the RemoteCommand one though because it looks cleaner to me
- hprotagonist 4y agoApparently the RemoteCommand way (which had never occurred to me!) can break other tools like scp or the like. The advantage I had in mind of using the rcfile is that it's something i configure once and then applies no matter where i ssh from.
- CGamesPlay 4y agoFrom elsewhere in this thread, it doesn’t break scp any more! https://news.ycombinator.com/item?id=32488843 https://news.ycombinator.com/item?id=32488843
- sneak 4y agossh root@remotehost “apt update && apt install -y byobu && byobu-enable” Much simpler IMO.
- hprotagonist 4y agomaybe, but it scratches a totally different itch. your proposed solution certainly doesn’t result in automatic use of tmux over ssh.
- sneak 4y agoIt does: that's what the byobu-enable part does. It modifies the .profile or .bashrc or whatever. All subsequent remote logins to that user account will automatically start/reattach to byobu (which uses tmux backend by default iirc).
- hprotagonist 4y agoso the same thing i did but more convoluted and requires a distro package and a service? nah.
- sneak 4y agoIt doesn’t run a service, it just modifies the user’s login scripts to start byobu/tmux on login, just like yours.
- olifante 4y agoHow about SSH straight into screen? Here's how to define a shell function for quickly attaching to an existing screen session after connecting via ssh (or creating a new one if none exists): sshcreen () { ssh -t "$@" screen -xRR } Works with bash and zsh. Usage is pretty simple: $ sshcreen user@example.com You can use normal ssh arguments, such as the port: $ sshcreen root@localhost -p 2222 Detach the session with CTRL-A + D, reattach by re-running the sshcreen command you previously used. PS: repurposed my comment from a recent discussion: https://news.ycombinator.com/item?id=32486892 https://news.ycombinator.com/item?id=32486892