How to enable root SSH login in amazon EC2 instance
In amazon EC2 instances, by default SSH login is done using keys. And the root login is disabled for security reasons. But times come when we have to enable remote SSH login as root. My situation came when I was doing xstream installation. I had to enter my root ssh details in their dashboard to initiate the installation. So, here I am going to show, what I did to enable root login using password in amazon EC2. The steps below were done in Ubuntu 14.04 64-bit.
First lets enable login using password, to do this, change the line in /etc/ssh/sshd_config
toPasswordAuthentication no
PasswordAuthentication yes
you can use Match block to narrow the permission to selected ip or user.
Second step is to enable root login through SSH. Lets change the line in /etc/ssh/sshd_config
toPermitRootLogin without-password
PermitRootLogin yes
Third step is to change the file /root/.ssh/authorized_keys file and remove the text before ssh-rsa. The text to remove is highlighted in red.
no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command=”echo ‘Please login as the user \”ubuntu\” rather than the user \”root\”.’;echo;sleep 10″
ssh-rsa AAAAB3NzaC1yc2E0000DAQABAAABAQC9+9P2K0Fxa/tWoelrsCOgZt5lt2hjgwhPzCZG49eyWaTYYhMGLYOnj0rdzlEHk997HpZ2piF9Ftfdx5Hx71dMryv0FqOITvRay/hFCVMXd6diStSHp9eWKx0iULWy0aaaSpWazlgdvJUr6C7Aolt2TU9Gcj+bIxH4lv3RCTpLLLtlqhBhv8wb24xKSw+khpDuy83zWKkzRsZpIpYXVVEslUZD491yTC9xTg0tn2XRVeC82fWCdmR6bwYMbPY/EhTnTjJCwLirRX3123+hWahddyYD6brfE8yX6liRLLFPlBsxHNkAreisFO3EzBqwKNEqQH1EvMWyHLJx9v672Z MyCrazyFunKey-normal
Now, restart ssh using the command:
You should be ready to SSH as root with password.service ssh restart
Note: Enabling root login may impose security risk, so disable it when you don't need it.
Comments
Post a Comment