Mantener las sesiones SSH abiertas

  • english
  • spanish

Sometimes SSH sessions die. At work I usually have several ssh sessions with a number of servers, and depending on the configuration of some intermediate router/firewall some TCP sessions get closed after a little while, the SSH sessions die and you have to log back in again.

To prevent this you can instruct sshd to implement some kind of keepalive mechanism preventing the TCP sessions from dying, by including these options on the sshd_config file:

KeepAlive yes
ClientAliveInterval 60

csshX

  • english
  • spanish

Some time ago I wrote an article about Cluster SSH.

Now that I’m using a Mac at work too and am working with clusters again, I’ve googled for a MacOS X-based program similar to cssh. And of course, there’s a guy who has done it! csshX is a different implementation of the same idea, this time written on perl instead of TCL/TK and using OS X’s Terminal.app.

Works like a charm.

Grande Debian, y grande screen

Este finde pasado he actualizado la Debian del Slug de Etch a Lenny. En remoto desde Alicante, a ratos y a lo largo de los tres días (viernes-domingo). XDDD

Cómo molan dos cosas:

  • dist-upgrade de una plataforma no sé si minoritaria, pero desde luego menos extendida y probada que i386, sin problemas. Todo a la primera. Yay!
  • screen. En remoto con una hardware tan justito y lento como el slug hubiera sido imposible. Con screen: abre sesión, “aptitude full-upgrade”. Apaga el ordenador, cena con amigos, vuelves a casa, ssh, screen … mira, pregunta algo. Respondes. Apagas y a dormir. Al día siguiente otra vez … luego desde casa de un colega …

Son pequeños detalles que al final te acostumbras a ellos y creo que no los valoras en su medida, si no te paras a pensar lo coñazo que hubiera sido tener que reinstalar, que la actualización no fuera bien y al reiniciar no arrancara, o no haber podido ir entrando y saliendo de la sesión durante tres días sin tener que mantener el ordenador encendido y la conexión ssh abierta (y sin cortes con un 3G de Yoigo!).

Bravo!

tar stdin/stdout

  • english
  • spanish

The tar command, like many other UNIX commands, can use stdin/stdout as its input/output target by using “-” instead of a real file.

What’s this useful for? For example, copying a full directory tree while keeping dates, ownerships and permissions, locally or remotely with ssh.

$ tar cf - . | ( cd /some/other/dir ; tar xfv - ) $ tar cf - dir | ssh usr@srv "tar xfv -"

cssh: Cluster SSH

  • english
  • spanish

cssh.jpg

Cluster SSH (cssh) is one of mankind’s greatest achievements. Really. Or at least, from a sysadmin point of view. :-) It’s one of those programs that, once you know it and start using it, you wonder how were you able to survive all those dark years without it.

cssh takes a username and several IP addresses on the command line, and opens a SSH session against each of those servers on an independent xterm window. Then, you can click on any of these windows and work independently with that particular server, or go back to the cssh console and write there, and ssh will retransmit each keypress to every SSH session.

This is a very useful tool when working with server farms, clusters, etc. For example lately I’ve been doing some monitoring and maintenance tasks on a 32-server farm on a major ISP: one by one each config modification would have take hours, with cssh it is a matter of minutes. :) Besides, as it replicates every keypress, it even works with text editors like vi: you can edit a file on every server at the same time, navigate through it, modify it… in parallel on every server. You have to be very careful when doing this, though. ;)