Is it possible to login via terminal in os x?
I found a solution to what I wanted so I'll post it just in case anyone is looking for something similar:

At boot time I launch a daemon that executes the following script:

#!/bin/bash
osascript -e 'tell application "System Events" to key code 126'
osascript -e 'tell application "System Events" to keystroke return'
osascript -e 'tell application "System Events" to keystroke "password_here"'
osascript -e 'tell application "System Events" to keystroke return'


In the login screen the script selects the first user account with the up arrow (key code 126),  then an enter (keystroke return) brings the textfield to input the password and finally another enter to login.

IF there's an error during the execution of the script, then you still have the login screen to authenticate the user.