How to enable root access using password in Amazon AWS EC2 instances
By default, password ssh access is disabled, and also root ssh access is disabled. Initially we can only login into an AWS EC2 instance using a pam key.
In this article we will see what we need to do to make possible ssh login for a normal user and for the root user in a AWS EC2 instance.
After you have created your instance and managed to login using the pam key follow the steps bellow to enable password ssh for root and other users.
For this we need to edit the /etc/sshd/ssh_config file
For root login enabling
- you will need to uncomment the PermitRootLogin yes line.
- comment the line PermitRootLogin forced-commands-only.
For password login
- uncomment line PasswordAuthentication yes.
- comment line PasswordAuthentication no.
PermitRootLogin yes -- Uncomment
# Only allow root to run commands over ssh, no shell
#PermitRootLogin forced-commands-only --comment
# EC2 uses keys for remote access
Next we need to restart the sshd service so the new configuration will get used.
[root@aodba]# /etc/init.d/sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
Now your AWS EC2 instance will be accessible by user/password.
- i don`t recommend login in using the root user, this can be dangerous and does not follow the best practices.
- also user access using password is a quite risky.