- Newest
- Most votes
- Most comments
Hi,
You code looks good.
But, since your message is ""Authentication failed.", did you validate via EC2 Instance Connect that the same key allows you to access the EC2 instance? This will clear potential key-related issues.
Also, I would suggest to activate paramiko's logging at DEBUG level to better see what's happening when connection is initiated: you may have a routing and sec group issue between your Lambda and your EC2.
Best,
Didier
I resolved the issue. The problem was related to the versioning of the paramiko library and its dependencies. The code started working after I updated the libraries to the following versions:
- paramiko==2.9.1
- cryptography==2.7.0
- bcrypt==3.1.7
(Python: 3.8)
Did you open SSH to the world in the Security Group? I highly recommend you not do this. Rather, connect the Lambda to the VPC and only allow private IPs to SSH in the SG.
Thank you for your recommendation. I have started working on it. However, I am facing an issue. Without connecting the lambda function to the VPC, the code works fine and I am able to SSH into the EC2 instance. But when I connect the lambda function to the VPC, I get a timeout error.
Relevant content
- Accepted Answerasked 8 months ago
- asked 9 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 3 years ago
It works fine when running locally but run through lambda function it gives me this error