Our ISP connections usually suffer cuts randomly, leaving ssh sessions open until timeout happens. I used to launch screen at first command, but sometimes I forget them, and ended with multiple ssh or screen sessions over the same boxes.
Put it on ~/.bashrc and source it.
ssh ()
{
if [[ "$2" == "" ]]; then
command ssh "$1" -X screen -aAdr -RR "SSH+SCREEN" /bin/bash;
else
command ssh $@;
fi
}
When you fire an ssh connection without arguments, it try to reattach a session named "SSH+SCREEN". If the session exist, simply resume it. If the session doesn't exist, it launchs /bin/bash.
Simply, but elegant trick.
But.. What happens ssh has an argument?
Simply skips session reattachment and launch command on remote host.
No hay comentarios:
Publicar un comentario