- Newest
- Most votes
- Most comments
Thanks for the input - enabling root login worked and two further questions.
On /etc/ssh/sshd_config - I removed "prohibit-password" from the line and left "PermitRootLogin" only - this made it work but if my app is only needing root access via TCP port X - is it OK to leave this root login enabled?
Which SSH keys need to be copied? Is it just one? Where the SSH key needs to be copied to allow access given that a new user that is part of the sudo group has been created?
Many thanks.
In Ubuntu on AWS, there is no default root password, and the root account is typically locked. You connect using the ubuntu user with SSH key-based authentication. Here's how to manage access:
- SSH Access: Use the ubuntu user with your SSH key.
- Set Password for ubuntu: If needed, log in via SSH and use sudo passwd ubuntu to set a password.
- Enable Root Login (Not Recommended): Set a root password with sudo passwd root, then modify /etc/ssh/sshd_config to allow root login.
- SFTP Access: Ensure your SFTP client uses the correct private key and ubuntu user.
- Create an Admin User: Add a new user with sudo privileges and copy the SSH keys to allow access.
These steps will help you securely manage access to your Ubuntu instance.
Hello,
By default, like you said, the root user or any other Linux user does not have a password, so you have to set a password for any user.
You can follow the steps provided in the below document to set the password of any user.
[+] https://asvignesh.medium.com/enable-root-access-for-the-linux-ec2-instances-ead5cea6ed70
Relevant content
- asked 3 months ago
- AWS OFFICIALUpdated 3 months ago

Here's how to create SSH keys https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html
This Ubuntu page is a few years old but the content in it is still good https://help.ubuntu.com/community/SSH/OpenSSH/Keys
It's advisable not to have root login enabled, but instead to login as a non-root user (for Ubuntu EC2 instances this user is called ubuntu) and then elevate to root privileges using
sudo.if your app only needs (e.g.) port 443 to be open then only opening this port means that your app will run. You won't have access to administer the host unless port 22 is also open to allow SSH (unless you have another way of logging in, such as Systems Manager).
And if you have port 22 open then (i) you shouldn't allow direct root login; and (ii) don't protect it with a password, because that can be guessed by an attacker.