Open a terminal or SSH client on your local machine.
1. Establish an SSH connection to your EC2 instance using the key pair associated with the instance. Replace your-instance-ip with the public IP address or DNS name of your EC2 instance, and your-key.pem with the path to your private key file:
ssh -i your-key.pem ubuntu@your-instance-ip
2. Switch to root with:
3. Once connected to your EC2 instance, enter the following command to set the default password:
You will be prompted to enter a new UNIX password. Make sure to choose a strong and secure password.
After that, we will edit the configuration to modify the ssh login system for password. So, letâs open the configuration file with a nano editor. This will let us edit the default configuration.
change PasswordAuthentication no to PasswordAuthentication yes
Next, we need to restart the sshd by running this command:
service sshd restart
Now you can Run this command, and then give the password.