Question as title. Why is this, I have used the ssh command: ssh -i mykey.pem [email protected] But i get that error, find nothing on google. What am I doing wrong?
Verify that your instance is ready Check your instance to make sure it is running and has passed its status checks. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Instances, and then select your instance.
To connect from the Amazon EC2 consoleOpen the Amazon EC2 console. In the left navigation pane, choose Instances and select the instance to which to connect. Choose Connect. On the Connect To Your Instance page, choose EC2 Instance Connect (browser-based SSH connection), Connect.
You log in as ec2-user
as Klaus suggested:
ssh -i key.pem ec2-user@host
... and then you use sudo
to run commands. E.g., to edit the /etc/hosts
file which is owned by root and requires root privileges: sudo nano /etc/hosts
.
Or you run sudo su
to become the root
user.
By default root
user is not allowed to login but you can use ec2-user
as indicated by others.
Once you login with ec2-user
you switch to root
and change the SSH configuration.
To become the root user you run:
sudo su -
Edit the SSH daemon configuration file /etc/ssh/sshd_config
, e.g. by using vi, and replace the PermitRootLogin
entry with the following:
PermitRootLogin without-password
Reload the SSH daemon configuration by running:
/etc/init.d/sshd reload
The message Please login as the ec2-user user rather than root user.
is displayed because a command is executed when you login with the private key. To remove that command edit ~/.ssh/authorized_keys
file and remove the command
option. The line should start with the key type (Eg. ssh-rsa).
(*) Do at your own risk. I recommend you to leave always a console open just in case you're not able to login after you make the configuration changes.
For reference you can read the man pages:
man sshd_config man sshd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With