Skip to Content

ERROR: AuthorizedKeysCommand /usr/share/ec2-instance-connect/eic_run_authorized_keys username SHA256:ecphulTPPp7xHnSCVkuQH2fcXemYKjT8xFftheRDz+s failed, status 22

How to solve: AuthorizedKeysCommand /usr/share/ec2-instance-connect/eic_run_authorized_keys username SHA256:ecphulTPPp7xHnSCVkuQH2fcXemYKjT8xFftheRDz+s failed, status 22 ?


Overview: This article helps to resolve EC2 SSH login issues caused by the ec2-instance-connect service by removing the package and restarting the SSH service.


Step 1: This error usually occurs when the EC2 Instance Connect service is misconfigured, malfunctioning, or not needed but still enabled on the instance. It can be resolved by removing the relevant package using the below command

root@server ~]# apt-get remove ec2-instance-connect

Step 2: Restart the SSH service and ensure that systemd has recognized any changes made to its configuration files.

root@server ~]# systemctl restart ssh
root@server ~]# systemctl daemon-reload

Additionally, there is a configuration file at '/usr/lib/systemd/system/ssh.service.d/ec2-instance-connect.conf' associated with this process.