You are here

how to enable root login on centos cloud images

i have been experimenting with ansible lately, and ansible uses ssh to run things as root. but the centos cloud images are set up in such a manner that you need to first logon as centos then sudo into root. not optimal for me. my private cloud's instances all have a single user called root. so i needed to reverse whatever the centos group did to lock my root user out

its actually a two step process

the first is to enable root logins via ssh

sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sed -i 's/GSSAPICleanupCredentials yes/GSSAPICleanupCredentials no/g' /etc/ssh/sshd_config

service sshd restart

the second and this is not recommended in production is to replace the root user's authorised key file

cp /home/centos/.ssh/authorized_keys /root/.ssh/

and voila!

let me know in the comments below why you needed to enable root login