ssh – automatic remote login

Since I don’t do this often enough to remember – here’s the procedure summarized (for Linux and OS/X, on Windows use putty):

me@here is username me at ip/hostname here
user@there is username user at ip/hostname there

me@here$ cd
me@here$ ssh-keygen -t rsa

press return a few times, don’t enter passphrase. This will create a public/private RSA key pair in your .ssh folder

Create the .ssh directory on the remote device (if it doesn’t already exist), and then add the local public rsa key to it’s list of authorized keys:

me@here$ ssh user@there mkdir -p .ssh
user@there's password:
me@here$ cat .ssh/id_rsa.pub | ssh user@there 'cat >> .ssh/authorized_keys'
user@there's password:

the next time you ssh user@there you will not be prompted for a password.

Note that some systems might require the following:

  • Placing the public key in .ssh/authorized_keys2
  • Changing permissions of .ssh to 700
  • Changing permissions of .ssh/authorized_keys2 to 640


git ssh keys on Windows

If you install git on Windows, the ssh key will be in directory

c:Program Files (x86)Git.ssh

If you have linux tools for windows installed, the .ssh folder it will use will be in your user directory

Lua with nginx

Openresty is an excellent piece of work that enables combining Lua scripting with the power of nginx, thereby giving you Lua as a server side scripting engine. Installing it is simple – just get the stable or latest version from the site, open it, ./configure, make and sudo make install.

On a clean Ubuntu, you will need to add the openssl and pcre libraries before doing the above so simply run:

sudo apt-get install libpcre3-dev
sudo apt-get install libssl-dev

and then follow the above steps.

Extensive documentation and sample snippets for openresty are available on the nginx site on the page for the HttpLuaModule

On a fresh Ubuntu, you might get all kinds of locale warnings or errors and get giberish when viewing foreign language files in the console – the solution:

sudo apt-get install language-pack-en-base
sudo dpkg-reconfigure locales

Calculating Hebrew Holidays

hebcal is a nice utility that compiles on all major platforms and calculates the Hebrew holidays using a perpetual calendar.

iconv is an amazing piece of work that can convert between zillions of encoding formats and is also available for all major platforms.

By default, just running hebcal displays the current year’s Hebrew holidays in English. Adding the parameter -8 displays them as 8-bit Hebrew (ISO-8859-8-Logical), which was gibberish on my console. To display the Hebrew holidays in UTF-8 Hebrew I just did the following:

hebcal -8  | iconv -f ISO-8859-8 -t UTF-8

Works like a charm.

By the way, if you want to convert the encoding of a file (say cal.txt) using iconv but you have no idea what the current encoding is, from a linux console, just issue the following

file -i cal.txt

Note that for non-unix platforms where you don’t have the file command you can try and use chared or simply drag the file to your favorite Internet browser. If it is displayed correctly check what encoding was detected by the browser and if not, play around with the encodings until it does…

After you find the current encoding, you can then check if iconv supports it and the parameter iconv requires by issuing:

iconv -l

Ubuntu – Accessing sqlite3 from Lua

I thought this would be trivial but ended up fighting with various solutions until I found one that worked without requiring additional configurations.

So first you might need to install the sqlite3 development libraries (which are needed to compile the Lua sqlite3 connector):

sudo apt-get install libsqlite3-dev

install luarocks if you don’t have it

sudo apt-get install luarocks

and finally, install lsqlite3:

sudo luarocks install lsqlite3

Web page is at this site and you can find some usage examples here