简体   繁体   中英

Is it possible to connect to ec2 instance as root user by using the PEM file?

I'm trying to connect to an EC2 AWS instance but when I tried to install PHPMYADMIN the linux console asks me for the root user password, which I forgot about. Could anyone please know how to use .PEM file to login as the root user? I tried sudo su command but it still asks me for the root user. Any help is appreciated.

Disclaimer: It is not recommended to login as root.

But still if you want to, then:

  1. Allow PermitRootLogin in /etc/ssh/sshd_config
  2. Restart SSH service
  3. you need to paste the existing public key which is in the /home/ec2-user/.ssh/authorized_keys to /root/.ssh/authorized_keys

Now you should be able to login as root using the .pem key.

You don't need your root password if you are running sudo su - , you need the password of the user you are running the sudo command as. Provided that the user has sudo privileges as root. Then you can just run as root:

yum install phpmyadmin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM