Saturday, August 18, 2012

How to log into AWS instance using password authentication

By default SSHD in linux instances in AWS are started with password authentication set to NO. For good resaons. Clear text password authentication is NOT as secured.
However for development instances or sandboxes, it might provide a "convenience" that may be worth.
To enable password authentication to AWS linux instances, modify parameter PasswordAuthentication parameter in file sshd_config and then restart the sshd process.
For example...
1root@domU-12-31-39-00-7C-94:[/etc/ssh]
2$ pwd
3/etc/ssh
4root@domU-12-31-39-00-7C-94:[/etc/ssh]
5$
6$ vi sshd_config
In the VI editor...
1# To disable tunneled clear text passwords, change to no here!
2PasswordAuthentication yes # <<<< we enabled this!!!!
3#PermitEmptyPasswords no
4# Changed to no per AWS
5#PasswordAuthentication no
Now restart SSHD process.
01$ sshd
02sshd re-exec requires execution with an absolute path
03root@domU-12-31-39-00-7C-94:[/etc/ssh]
04$ which sshd
05/usr/sbin/sshd
06root@domU-12-31-39-00-7C-94:[/etc/ssh]
07$
08root@domU-12-31-39-00-7C-94:[/etc/ssh]
09$ service /usr/sbin/sshd restart
10/usr/sbin/sshd: unrecognized service
11root@domU-12-31-39-00-7C-94:[/etc/ssh]
12$ service sshd restart
13Stopping sshd: [ OK ]
14Starting sshd: [ OK ]
15root@domU-12-31-39-00-7C-94:[/etc/ssh]
16$
Now SSHD process is started with password authentication enabled. If we remove the key from the putty profle and open a telnet connection, we'll be prompted for userid and password.
We should be able use a valid linux user with password to login.
1login as: oracle
2oracle@ec2-23-22-205-159.compute-1.amazonaws.com's password:
3oracle@domU-12-31-39-00-7C-94:[/home/oracle]
4$
5oracle@domU-12-31-39-00-7C-94:[/home/oracle]
6$
7oracle@domU-12-31-39-00-7C-94:[/home/oracle]
8$
That's it. Be careful when using this technique.

No comments:

Post a Comment