In the following is a quick guide to creating a new user (we will be calling this user “username”) on a Amazon Cloud EC2 instance with Ubuntu 12.04 AMI
CREATING NEW USER
We will begin by adding the new user and setting the new users password
$ sudo adduser
This command will then take you though the setting up a password. You can check the users that you now have my opening the /etc/passwd file
Now we are going to make use of a unix command called “visudo”, this allow you to edit the sudoerrs file in a concurrent access safe way. Before using visudo, we need to check that the default editor is the one that we would like and change it, if required:
$ sudo update-alternatives –config editor
Now you will be given a dialogue where you can select your favourite text editor.
Now add the following line to the file that has been opened:
Now exit the machine and log back in as ubuntu.
You can now switch to this newly created user with
$ cd /home/
GENERATING KEYS FOR SSH TO NEW USER
We are now going to generate the public key for public/private key pair that will be used later to SSH directly into this new user
$ ssh-keygen -b 1024 -f mykey -t dsa
This line has generated two files, the public key mykey.pub and the private key mykey. To be able to ssh from a local machine to the new paws user on this remote machine, we need to place copy the contence of paws.pub into /home/username/.shh/authorized_keys and we need to have a copy of the private key (called mykey) on the local machine