I've just setup my EC2 server following this video here exactly - http://www.youtube.com/watch?v=bBajLxeKqoY
I even chose the same server type, everything went well until it asked for the root password to my EC2 server...
Any suggestions?
I've just setup my EC2 server following this video here exactly - http://www.youtube.com/watch?v=bBajLxeKqoY
I even chose the same server type, everything went well until it asked for the root password to my EC2 server...
Any suggestions?
Updating this answer because of the activity:
Depending on if the system is ubuntu or Rhel the user varies.
For ubuntu it is
ssh -i my-pem-file.pem ubuntu@my-ec2-instance-address
For RHEL it is
ssh -i my-pem-file.pem root@my-ec2-instance-address
Connecting to an ec2 instance does not require a password, it would require only a pem file and this is how you connect to it
ssh -i my-pem-file.pem ec2-user@my-instance-address
and remember to chmod 400
your pem file before ssh'ing
If you need to do things as root once you are in as ec2-user, use sudo su
- that gets you to root and doesn't need a password. Somethings you do need that for, like looking at the tomcat log files
I had the same problem and after a lot of struggle, I read this page again:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
Notice in the 4th topic it talks about the user name. It is usually ec2-user
but if you are using RHEL5 distro it can be root
and if you are using the Ubuntu the user name will be ubuntu
- which was my case.
So alternatively try those:
ssh -i my-pem-file.pem ubuntu@my-ec2-instance-address
for Ubuntu
or
ssh -i my-pem-file.pem root@my-ec2-instance-address
for RHEL5
Hope it helps!
You will be asked for password when you enable PasswordAuthentication yes
in your sshd_config. Try changing that to no. that should fix it.
Just for anyone else that might have the same problem
If you've moved/copied the pem file from another machine, the owner of the file may be different to the user that is running the ssh client. To change the owner of the file:
sudo chown <currentusername> <filename.pem>
Please use --query 'KeyMaterial'
while generating key.
Info:
keyMaterial - an unencrypted PEM encoded RSA private key.
In my case, we had been copying a text file to keep a ubiquitous key. Someone accidentally added characters to this file, and we started getting prompted for a password from the now-corrupt .pem file, when we had never set a password.
chmod 400 pem_file
ssh -i /path_to_the_pem_file ec2-user@ServerIP
or
ssh -i /path_to_the_pem_file ubuntu@ServerIP
root access is prohibited by default by AWS AMIs.
hope it helps.
In my case, the problem was the file's break type. Try this:
1.- Open the .pem file with TextWrangler
2.- At Bottom of app, verify if the Break Type is "Windows(CRLF)".
Regards
This is the way to connect:
ssh -i /path/my-key-pair.pem ec2-user@public-ip
Now, instead of ec2-user, it could be root, or centos, or ubuntu, or something else. You can check under the "Usage Instructions". If it's not there, and you've tried all the above users, find out from the documentation that came with the AMI.
There is one bug on AWS that cost me a lot of time. If you're launching an instance from a saved AMI under "Images > AMIs", note that it uses the original keys of the running instance it was created from. When launching the AMI, it will prompt you to choose a new key, and even show such key under the description, but the truth is those keys will never work!
So if you're using a custom/saved AMI you'll have to either get the original keys and use them, or just create a brand new one from AWS or the market place. If you haven't created the AMI or can't remember where it came from, look under the details tab. You can then launch a new instance or create a new AMI from the same source. This will then use the keys that you specify.
Check your .pem file is not corrupt. Using this line
openssl rsa -check -in test.pem -noout
It should return RSA Key OK. If it doesn't then there is most likely a problem with some sort of formatting or something in your pem file.
It could be a Linux problem. But there is also a chance that you use the wrong address/key (you started a new instance but still using the old address; or 2 pem have similar name, used the wrong one), "ssh with non-existing user".
I am using TurboLinux instance, on Mac OS system, please try this command: ssh -i xxxxx.pem root@xxx.xxx.xxx.xxx (public address of allocated VM) I can get through without asking password anymore.
In case someone else bumps into this, the solution for my problem was that I had to run it with sudo
:
sudo ssh -i my-pem-file.pem root@my-ec2-instance-address
For me, the issue was that I had created an AMI from an existing instance, so when I launched the AMI, even though I selected a new key, the instance's original key was what worked.
Login to Amazone console in browser: https://us-east-2.console.aws.amazon.com/ec2/xxxxxxxx
Click on instances from left panel -> then select your instance -> click on connect button at top right
You will see a window open and there will be a button ssh Client
Here you can see exact command to connect with your instance.
You should use the *.pem instead of a root password. Once you have logged in use passwd
to set a password.