I've changed following line in the ssh_config file to enable password logging:

PasswordAuthentication Yes

After that I've reboot the ec2 instance. Now trying to ssh but it saying refused connection.

ssh -vvv -i _key_.pem ubuntu@instance_ip

Output Log:

OpenSSH_7.4p1, LibreSSL 2.5.0`
debug1: Reading configuration data /etc/ssh/ssh_config`
debug2: resolving 'instance_ip' port 22`
debug2: ssh_connect_direct: needpriv 0`
debug1: Connecting to 'instance_ip' ['instance_ip'] port 22.`
debug1: connect to address 'instance_ip' port 22: Connection refused`
ssh: connect to host 'instance_ip' port 22: Connection refused

I've checked the port 22 which is allowed in the security group.

Now I'm unable to login to the server. Is there any way to ssh to the instance or recover data and config files in it?


In sshd_config, while keywords are case-insensitive, arguments are case-sensitive. From the manual:

         Specifies whether to use password authentication.  The argument to this keyword must be “yes”
         or “no”.  The default is “yes”.

Yes is not yes, so the configuration is invalid, and the ssh daemon is not starting, which is why you TCP connection on port 22 is being refused -- no daemon is listening.

  • sorry for late response, @DopeGhoti :: is there any way I can revert the settings? – Airful Sep 19 '17 at 5:22
  • Did you take a snapshot of the instance before effecting the change? If not, there may not be a simple way, as AWS instances do not have a traditional 'console access' mechanism. You might be able to mount this instance's drive on another instance and change the file that way. – DopeGhoti Sep 20 '17 at 16:27
  • thanks, I've created new instance and setup everything. sshd_config is okay now :) – Airful Sep 21 '17 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.