Change default password of root user on aws ubuntu ec2 instance
First ssh into your server using the ssh key.
ssh -i "Mysecretkey.pem" ubuntu@ec2-ip.compute-1.amazonaws.com
Once you are logged in, switch to root user with the following command
su root -
Then run passwd root
It will ask for the new password
New password: // Enter new password here
Retype new password: // Re-Enter new password here
Once everything is correct, you will get the success message
passwd: password updated successfully
Congratulations, you have successfully changed your root password.
Also, to change the password of the specific user, you can repeat the same procedure, just provide the different username with the switch user (su) command.
That's it !