TimeLinux1

Wednesday, February 27, 2013

How to enable Password-less ssh in a cluster?

If you are an admin to a clustered environment and frequently need to remote login (via ssh) to the cluster from your local node (eg laptop) OR from one node in the cluster to other nodes in the same cluster, you may have wondered --"Wouldn't it be nice to not have to provide password every time you login to a remote system?" Well to answer that its possible to enable what is called password-less ssh (secure shell) session between the nodes and it can be achieved in 3 easy steps.

1- Generate public keys on each node
2- Copy the public key of every node to every other node in the cluster in their 'authorized_keys' file
3- And test it out.

In the following example, we are taking a two node cluster and want to enable password-less ssh between the two nodes in the cluster. 
Node 1 IP Address -  10.10.80.102
Node 2 IP Address -  10.10.80.103

On Node 1:
Step 1:  Generate Public keys

[root@10.10.80.102 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
e8:f8:fe:c7:f2:c6:89:3d:51:78:df:6f:f1:a3:90:91 root@10.10.80.102
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|           .     |
|       .  . +    |
|      . S  E . . |
|     o    . o ...|
|    . .  = =    +|
|     .  o O .  .+|
|     .o..=.. ....|
+-----------------+
[root@10.10.80.102~]# 

Then go to ~/.ssh directory and verify the public key file is present.

[root@10.10.80.102 ~]# cd .ssh
[root@10.10.80.102 .ssh]# ls -l
total 8
-rw-------. 1 root root 1675 Feb 27 02:53 id_rsa
-rw-r--r--. 1 root root  394 Feb 27 02:53 id_rsa.pub
[root@10.10.80.102 .ssh]# 

Step 2:
Copy the public key of every node to every other node in the cluster in their 'authorized_keys' file

Then copy over the public key file (of Node 1 ie 10.10.80.102) over to Node 2 (10.10.80.103 in this case) in the file called ~/.ssh/authorized_keys with permissions 600. A handy tool called ssh-copy-id does it for you as shown below.

[root@10.10.80.102 .ssh]# ssh-copy-id -i id_rsa.pub 10.10.80.103
The authenticity of host '10.10.80.103 (10.10.80.103)' can't be established.
RSA key fingerprint is 06:80:d2:e9:05:c8:28:4d:bb:b3:09:5a:c1:47:bd:f4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.80.103' (RSA) to the list of known hosts.
root@10.10.80.103's password: 
Now try logging into the machine, with "ssh '10.10.80.103'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

[root@10.10.80.102 .ssh]# 

Step 3:
Test it out

[root@10.10.80.102 .ssh]# ssh root@10.10.80.103
Last login: Wed Feb 27 02:49:08 2013 from 10.250.0.54
[root@10.10.80.103 ~]#  [[[ no password asked ]]]
Now just repeat steps 1, 2, 3 on all nodes on your cluster. And you are all set !!



Sunday, February 17, 2013

Logitech Bluetooth Keyboard K810 with Fedora 17

So received my brand new Logitech Bluetooth Illuminated Keyboard K810 from Amazon a few days ago.
Had been wanting a wireless keyboard for a long time to unclutter the desktop workspace at home.
[[BTW I also went one further and got a wireless mouse too (Verbatim Wireless Mini Nano Travel Mouse 97470) and I write about it little later in this article.]]

What is good and appealing about this keyboard (besides its wireless feature) is its Illumination feature.
In low light conditions, a gentle light comes through each key, meaning all the keys are visible in the dark with the letters themselves glowing. This is important for me as I often work late and in the dark room (so not to disturb others while they sleep) and so having an illuminated keyboard is convenient, enhances typing experience by minimizing typos and also looks cool. Infact, I bought my Sony Vaio S series laptop mainly for the Illuminated keyboard feature. Having an external keyboard that is wireless and illuminated at the same time simply enhances the computing experience.

Ok now that we gloated a bit about the product features, lets talk tech.
As you already read, the keyboard is wireless and it communicates to the laptop via Bluetooth. So obviously, you would want your Bluetooth service turned on (some people turn it off to save laptop battery).

Now my concern about buying this keyboard (its not cheap btw, even on Amazon it costs about $90), was that I only use Linux OS (Fedora 17) and nowhere on Amazon website or even on Logitech's website does it state that this keyboard is compatible with Linux OS. Anyway, based on the notion that Bluetooth is a wireless standard and not any OS specific featu[root@ms-vaio ~]# rpm -qa | grep bluere, I went ahead and ordered the keyboard. I took the risk--if it did not work because of missing or incomatible drivers, I would have returned it back.

Fedora has its own inbuilt Bluetooth drivers and you can configure its settings via the System Settings > Hardware Settings > Bluetooth.
Once check Bluetooth on and also turn on Wireless Logitech Bluetooth keyboard, the system will try to detect the keyboard and 'pair' it. The bad news is the default Bluetooth driver in Fedora 17 wont be able to pair the keyboard. You can find out what Bluetooth driver you have installed by running the following command on a terminal:
[root@ms-vaio ~]# rpm -qa | grep blue

A little research on the web shows that the driver you need is called 'blueman'.
To install Blueman simply use yum (as root user on a terminal window):

[root@ms-vaio ~]# yum install blueman -y

And query the rpm database again for bluetooth -- see my example below:


[root@ms-vaio ~]# rpm -qa | grep blue
bluez-cups-4.99-2.fc17.x86_64
gnome-bluetooth-libs-3.4.2-1.fc17.x86_64
bluez-4.99-2.fc17.x86_64
pulseaudio-module-bluetooth-1.1-9.fc17.x86_64
blueman-1.23-5.fc17.x86_64
gnome-bluetooth-3.4.2-1.fc17.x86_64
bluez-libs-4.99-2.fc17.x86_64
gnome-shell-extension-remove-bluetooth-icon-0.3.0-1.fc17.noarch
bluez-hid2hci-4.99-2.fc17.x86_64
[root@ms-vaio ~]#

Then start the blueman applet from Gnome under Applications. Its called 'Bluetooth Manager'.
Dont select the app called 'Bluetooth' app under 'Services'--thats the default Bluetooth app from Fedora and doesnt work for this keyboard.
Note: to get to Gnome activities, simply point the mouse to your left top corner of the screen.

Then in the Blueman applet, click Setup in the menu bar > Select Input service. It will automatically detect your keyboard and pair it. And you are all set!
Bottom line is even though the neither Logitech nor Amazon does not mention compatibility with Linux/Fedora anywhere, this keyboard DOES work on Linux.
Linux is such a cool platform that you can make anything work on it yourself just with a few commands and some reverse-engineering. No other OS gives you that Freedom. Enjoy!!

PS: Infact, this keyboard supports 3 wireless devices at the sametime. You can pair your tablet, mobile phone and laptop all at the same time just by pairing them to the 3 bluetooth buttons on the keyboard.
Also, Like I said before I also got the Verbatim Wirelesse Mini Nano Travel mouse to increase the 'Wireless' experience. But that one works on USB technology (not Bluetooth), and therefore is much easier to setup and works out of the box. Plug and Play.