Archive for the ‘Shell scripting’ Category

I faced a problem with locales in terminal on Mac OS X Lion. Midnight Commander didn’t want to display cyrillic symbols in filenames, on remote Ubuntu I’ve been getting messages like “warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)”. The solution is fairly simple – add these two lines to ~/.bash_profile (by default is seems to be missing, so create the file):

# Setting for the new UTF-8 terminal support in Lion
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Thanks to Allen Bargi’s answer!

P.S.: Mountain Lion has the same issue and it gets solved in the same way.

Rarely but happens when you have to log in to a remote server using password instead of public-key authentication. It’s very easy to do:

ssh -o PubkeyAuthentication=no user@machine

It happened to me on Mac when I had the key in keychain and tried to log in to a different server with the same name. Keychain tried to supply my key.

MySQL over SSH tunnel

Posted: October 19, 2010 in MySQL, Shell scripting
Tags: , , , ,

Sometimes we face a problem when we have SSH access to the server, but not to MySQL.
Here is a simple workaround – SSH tunnel:

ssh -f -N -L LOCAL_PORT:127.0.0.1:3306 USER@HOST

This command allows you to map remote port to the local one via SSH tunnel.

  • LOCAL_PORT – local port to map to
  • USER – SSH username
  • HOST – remote host

Surely, you can map other ports as well.

When you mapped the port, you can connect to MySQL using your favorite client (you need to specify LOCAL_PORT as MySQL server port in connection settings).