Putty and tree – how to avoid weird characters (squares)

Character encoding is always a problem when communicating between Windows and Linux. And using the “tree” command is affected by this problem if you are connected to a Linux box using Putty on a Windows box. You will certainly get weird characters, probably squares.

For those who are not sure about what tree is. It is a command-line tool to list contents of directories in a tree-like format.

A solution to this problem is to force using plain ASCII characters:

tree --charset=ASCII

You can also have an alias for this command, so that every time you type “tree“, it will force tree to use the ASCII charset automatically.

alias tree='tree --charset=ASCII'

And this is an example of what you will get as an output:

|-- claws-mail-1000
|-- keyring-x803mg
|   |-- control
|   |-- pkcs11
|   `-- ssh
|-- orbit-gdm [error opening dir]
`-- virtual-user

[Ubuntu] Byobu: a very useful enhancement for GNU Screen

I’m now using Byobu (earlier known as screen-profiles, but changed to Byobu) everytime I ssh into one of my servers:

[local]$ ssh myserver
Last login: Thu Aug 13 11:03:58 2009 from ...
[remote]$ byobu -R


Byobu can be seen as a replacement for the “screen” command, though it is not really a replacement; It should be seen much like an addon or a plugin. It can also be used locally without ssh (I just find it useful with ssh). It shows very useful information (about the computer where screen/byobu is running) and acts just like screen, same commands (though it adds some more keybindings). See screenshot above.
Continue reading “[Ubuntu] Byobu: a very useful enhancement for GNU Screen”

How To use MySQL Administrator & Query Browser through SSH tunnel

I try to keep my VPS (Virtual Private Server) as light as possible. That’s also why I don’t have PHPMyAdmin installed and wouldn’t want to install it. The only way of accessing MySQL and executing commands is through the mysql CLI (Command Line Interface), but I don’t always remember the exact queries to create a user, database or to grant privileges.

I recently decided to look for some GUI (Graphical User Interface) tools to tweak and administrate a MySQL server. I found the quite well-known MySQL Administrator (and Query Browser).

MySQL Administrator
MySQL Administrator

The problem is that by default (and for obvious security reasons), my MySQL server is not accessible from the internet (only accessible by localhost itself). This is where SSH tunnels enter the action!
Continue reading “How To use MySQL Administrator & Query Browser through SSH tunnel”

Cron, SSH, Rsync, and a ssh key with a passphrase (Ubuntu)

I recently scheduled some backup tasks on my VPS using backup-manager which is a neat program for this job. Everything is fine for that.
Then I wanted to set up a cron on my home computer to download the backup archives everyday. This wasn’t as easy as it sounded at first.
You might even get those errors:

Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: unexplained error (code 255) at io.c(635) [receiver=3.0.3]

I need to connect to my VPS using a SSH key that is protected by a passphrase (password). This ssh key is added to my ssh agent (at login time).

The main problem is that cron is run using a restricted environment, meaning it doesn’t give environment variables like SSH_AUTH_SOCK.
This variable is needed by the ssh client in order to communicate with the ssh agent that will provide the information on the ssh key.

Here’s a workaround for it. It’s a quite secure way to fix this.
Continue reading “Cron, SSH, Rsync, and a ssh key with a passphrase (Ubuntu)”