How to Automatically Login to Ubuntu on Amazon’s EC2 Service

amazon ec2cloud computingUbuntu

< NEW >

My apologies, I didn't explain my goal very well.

I want to automatically "log onto" and start running any given program under a user account in Ubuntu. I guess this has very little to do with EC2 in particular.

For example, in windows server 2008, when I:

  1. follow these steps http://support.microsoft.com/kb/315231 to automatically log in a user
  2. add Firefox (or any program) to the windows users' start-up folder
  3. re-bundle the image

Running an instance of the re-bundled image virtually starts Firefox.

How can I accomplish this one simple task in Ubuntu?

And no, you cannot access a windows account that is automatically logged-in via the internet. You would still always need the password to view the user's desktop.

< / NEW >

< OLD >

I have finally created, registered, and ran my first AMI, and it starts up beautifully!

It is a slightly modified version of Eric's 8.04 Hardy w/NX Free Edition found here: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1428&categoryID=208

I have also followed instructions according to the official ubuntu page on enabling automatic login: https://help.ubuntu.com/community/AutoLogin

Along with adding firefox to the list of startup programs; I have firefox set to the official US government's time page so I know exactly what time it starts.

HOWEVER , firefox only starts when I login via my NX client – it doesn't start when I reboot the instance – which leads me to believe the automatic login function on ubuntu is not working.

How can I automatically login to ubuntu's gnome desktop and run firefox on an Amazon EC2 AMI Image?
< / OLD >

Best Answer

Turning off password checking on your EC2 boxes could mean that anyone can login and use them. That can be a problem. For instance, someone could run up a bill on your account.

Also, I don't know why you would want to run 100 instances all running firefox. If you want to automate the collection of web pages, consider looking at wget.

Firefox through X to/from a remote desktop is usually unacceptably slow.

I'm not using NX but you've made me curious about it if you think it is fast enough to support this sort of thing.

There is a way to do this sort of thing without NX; namely, with an X client (like a local ubuntu installation) and ssh with Xwindows forwarding. Perhaps this is similar enough that you can modify it for your needs.

The password requirement can be eliminated through the use of ssh public key authentication instead of turning off passwords on your ec2 boxes.

The ssh command to use is

   ssh -C -Y remoteid@remotehost.com firefox

or just

   ssh -C -Y remoteid@remotehost.com

and then execute whatever command you like from the remote shell.

Explanation:
-Y forward Xwindows from the remote host to the local host in trusting mode
-C compress Xwindows traffic

No Passwords: to do this without passwords in ssh run ssh-keygen, and generate a key pair you keep the private key in your .ssh/id_rsa and you copy the public key to the remote computer and paste it into .ssh/authorized_keys

If you decide you want a password after all, you can add a passphrase to your key if you like, but you only have to do that on the local computer, not the remotes. Or, you can delete the key out of .ssh/authorized_keys and ssh will use password checking instead of key checking when you log in.