Once you’ve created your , you will get a private key (generated during the server setup process) and a default UNIX user called ec2-user. By default password authentication is disabled (because it’s plain text password transferred over the internet). You can login using a ssh client from your PC using this command:
ssh -i /path/to/mykeypair.pem
If you’re on windows and you use Putty it might be slightly more tricky:
- First you need PuttyGen tool
- Once you’ve downloaded and installed it, open it and select File -> Load private key. Find your keypair file
- PuttyGen will display success message if your keypair is valid. Then select Save private key
- On your putty connection parameter, go to Connection -> SSH -> Auth and use the above saved file for Private key file for authentication
Generating Encrypted Password
Standard UNIX and commands can be used to manage users on Amazon Linux, however you first need to know how to generate encrypted password. Supposed I want to encrypt my password string “holasenior”, run following commands:
[]# python
Python 2.4.3 (#1, Jan 9 2013, 06:47:03)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import crypt; print
>>> crypt.crypt('holasenior','mysalt123')
'myOZ9FACMq7sA'
>>>
myOZ9FACMq7sA is your encrypted password. mysalt123 is an encryption salt to defent against dictionary attack.
Adding New User
To add new user “ironman” with password “holasenior” encrypted with salt “mysalt123″:
sudo useradd -p myOZ9FACMq7sA ironman
Changing Password of Existing User
To change password of existing user “ec2-user” to “holasenior” encrypted with salt “mysalt123″:
sudo usermod -p myOZ9FACMq7sA ec2-user
SSH with Password Authentication
WARNING: Using plain-text password authentication for SSH is dangerous, your password will be visible over the internet.
To enable password authentication, edit /etc/sshd_config file and find following line and change it to yes
PasswordAuthentication no