OpenSSH Escape Characters
Posted by bene - 10/05/08 at 11:05:24 amYesterday I discovered a terrific feature of OpenSSH while reading ssh(1): Escape Characters.
It’s a wonder that I didn’t accidentally noticed from it before, but that’s just a proof of how well it actually works.
Here’s how you go:
Just type ~? and make sure that the last you typed in was nothing or a newline. SSH will then show you the list of currently supported escape sequences:
~. - terminate connection
~B - send a BREAK to the remote system
~C - open a command line
~R - Request rekey (SSH protocol 2 only)
~^Z - suspend ssh
~# - list forwarded connections
~& - background ssh (when waiting for connections to terminate)
~? - this message
~~ - send the escape character by typing it twice
For me are ~C and ~# the most important commands.
One can open or close port forwardings in the command mode – which I could have used so many times
And because escapes are only recognized immediately after newline, you can still cd into your homedir using cd ~
libnotify over ssh
Posted by bene - 15/02/08 at 09:02:36 pmlibnotify is a nice desktop notification framework, very similar to Growl. It’s basically a client-server architecture: the desktop implements a notification-daemon where the clients send notifications to (via D-Bus).
In my case it’s notification-daemon-xfce and on the client side primarily galarm and pidgin (using a patched pidgin-libnotify plugin).
With notify-send you can also create your own notification. I wrote a little zsh wrapper function to get a notification when the command terminates:
# run some command and notify about the result via the notification-daemon
function run () {
$@
local error=$?
if [[ $error -eq 0 ]]; then
notify-send “`hostname -s` | terminated:” “$1 $2″ -i finish -t 0
else
notify-send “`hostname -s` | aborted:” “$1 $2″ -u critical -i undo -t 0
fi
return $error
}
The usage is quite simple:
# run sudo update-eix
All of this is nice but I decided to need notification of remote events as well.
I hate to wait or poll till a command on my server terminates, instead the server should notify me. ![]()
Additionally I run a WeeChat IRC-client 24/7 in screen and want a notification for (private) IRC messages.
Accomplishing my requirements is a tough task, but after some research I found this nice idea of Jared Quinn: libnotify-with-irssi-over-ssh.
The trick is to tunnel the notification through the terminal using the print pipe.
I adapted his scripts and patched them to fit my needs:
My favorite terminal is rxvt-unicode so the .Xdefaults entry looks a bit different:
URxvt.print-pipe: ~/scripts/unmarshal.pl
My unmarshal script collects the content of the pipe and sends the notification to the daemon:
unmarshal.pl (html)
…the WeeChat plugin (based on growl-notify):
…and finally the drop-in replacement for notify-send:
If notify-send is placed in /usr/local/bin/ on the remote host, you can just type something like run sudo updatedb and get a notification to the desk. ![]()
Powered by WordPress with GimpStyle Theme design by Horacio Bella. Get Entries and comments.