Wednesday, April 27, 2011

Thoughts on password preservation

Usually within the user authentication module of a system, username and password are preserved in a database or similar data structures, and moreover, the password should be encrypted first before being stored in the database for safety.

Here comes the issue about the encryption: should the encrypted password be associated with the username?
I don't know the answer (future work to do); but in my opinion, it should be.

Fact in User authentication of OpenNebula:
When doing the user authentication for oneadmin (default admin account), I always get the following error:
Error: [UserPoolInfo] User couldn't be authenticated, aborting call.
I digged deeper on this issue: I looked into the one.db and found that there is no password for oneadmin but I did set the password for it. Here is the output from user_pool table of one.db:
oid|user_name|password|enabled
0|oneadmin||1
 I fixed this in a stupid but effective way: by updating its password field with the encrypted password of another account (which has the same password), which means in this case, encrypted password is NOT associated with the username.

Additional notes to passwordless ssh login

There are plenty of tutorials about passwordless ssh login to remote machines. Here is a simple guide:
1. @local: Generate rsa key-pair (skip this step if it exists) with #ssh-keygen -t rsa
2. @local: Append the content in .ssh/id_rsa.pub to .ssh/authorized_keys on remote server
               #cat $HOME/.ssh/id_rsa.pub | ssh USER@REMOTE 'cat >> $HOME/.ssh/authorized_keys'
3. DONE

Additional notes:
SSH has a restricted requirement on the permission of $HOME directory on the remote machine. Here is something you need to check if the above method fails:

@remote: #chmod 755 $HOME
@remote: #chmod 700 $HOME/.ssh
@remote: #chmod 744 $HOME/.ssh/authorized_keys