Lucy Weatherford
Lucy Weatherford

Reputation: 5534

Connecting with SSH to Amazon EC2 requires pwd

I have just launched a new Amazon AWS EC2 instance. It is a Suse server.

I am attempting to connect to it through SSH using my private key. It has been 'Permanently added' to my 'to the list of known hosts.' with my private key.

However -

I am not logged in to the server. It is requesting a password. Though it is supposed to use my private key without a password. (as described here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html)

What should I do?

--

More details:

I ran it again with debug: added -v: ssh -v -i ...

These are the last few lines in the shell (up to here it seems to be fine) before I am asked for pwd:

    debug1: Authentications that can continue: publickey,keyboard-interactive
    debug1: Next authentication method: publickey
    debug1: Trying private key: my-private-key.pem
    debug1: read PEM private key done: type RSA
    debug1: Authentications that can continue: publickey,keyboard-interactive
    debug1: Next authentication method: keyboard-interactive

Upvotes: 0

Views: 1575

Answers (4)

Sirius Gao
Sirius Gao

Reputation: 1

i solved this by changing my proxy server from Hk to Japan. my ec2 instance is in japan, but my proxy server is in Hk, so it let me type pwd, but when i change my proxy server to Japan, no need to type the pwd

Upvotes: 0

MoA
MoA

Reputation: 71

On trying with user "root", it worked for me.

ssh -i root@server-name

The documentation says the user could be either ec2-user or root: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

Upvotes: 0

Kyle Kelley
Kyle Kelley

Reputation: 14144

If your local box is Linux

The first thing you want to make sure of is that you have your key loaded into ssh-agent and into ssh-add (on your client machine).

08:10:51 ~$ ssh-agent
SSH_AUTH_SOCK=/var/folders/ps/1dvr90bd6p3blnyrnpyxnryhv45qg1/T//ssh-K8VbUYmYYj4w/agent.9087; export SSH_AUTH_SOCK;
SSH_AGENT_PID=9088; export SSH_AGENT_PID;
echo Agent pid 9088;

Run each of these lines (to declare the variables you need). Then run ssh-add.

08:17:33 ~$ ssh-add
Enter passphrase for /Users/kyle/.ssh/id_rsa:
Identity added: /Users/kyle/.ssh/id_rsa (/Users/kyle/.ssh/id_rsa)

To put it all in one line:

$ eval `ssh-agent`; ssh-add

Workaround to make sure you're loading the right key

You can tell SSH to load a specific key using the -i option.

$ ssh -i ~/.ssh/other_rsa ec2-user@<ip>

Username woes

If this is an Amazon Linux box, the user is ec2-user. For some AMIs, they have other users set up (ubuntu on ubuntu). Check the documentation to see if they have any specific requirements.

$ ssh ubuntu@IP

Upvotes: 0

Lucy Weatherford
Lucy Weatherford

Reputation: 5534

I have just solved this. It is a bit of a workaround. The problem may have been the type of server used, Suse. I used ec2-user for username, but it may be different for different servers. This is the one for Amazon Linux AMI (and also for Ubuntu I believe), but apparently not for Suse. I stopped (/terminated) this instance, and launched a new AMI Amazon Linux server instance instead.

Connecting to SSH there worked like a charm. Using ssh -v -i my-private-key.pem [email protected] I was not asked for a pwd here.

Upvotes: 1

Related Questions