Hello, today a quick tutorial about AWS Session Manager and Amazon SSM Agent. If you are having problems connecting to EC2(Windows system), by Session Manager then you should read this article to the end. You will learn from it how I deal with such problems.
Before you start
Before you start, make sure you have a role connected to EC2 with the correct permissions. What those permissions should be, you’ll learn from this article: https://lepczynski.it/en/aws_en/session-manager-in-amazon-web-services-aws/
Fixing a problem with Session Manager
It often turned out that the Session Manager was having problems because the SSM Agent was not running.
How to fix it? What can be done to make it work?
Well, I connected via VPN to AWS and then to my machine via RDP. You should use a VPN, but if for some reason you don’t, just log into EC2 using RDP.
1) Situation when you are lucky
On EC2, open the services. If you just click start on Amazon SSM Agent
and it works, you’re in luck. Just make sure the agent still has the auto-start option enabled, otherwise the problem will persist.
2) A situation where you are not so lucky
If you are not so lucky and the agent is not starting up, but is throwing errors, maybe the problem is in the routing table. Turn on PowerShell and paste these 2 commands:
Import-Module "C:\ProgramData\Amazon\EC2-Windows\Launch\Module\Ec2Launch.psd1"
Add-Routes
This should fix the routing table. Now when you run the SSM agent it should work, at least it helps me.
3) Situation when you are unlucky
If by some miracle you still have the problem, you’ll have to look in the logs, unfortunately. You’ll usually find them in the directory …ProgramData\Amazon\SSM\Logs
…
Of course, you can also try removing the agent and reinstalling it.
Summary
It was an AWS Quick Advice article. If I helped and you like such short, quick tips, let me know in the comments.
I will then share a solution to more bugs that I encounter every now and then.
I made an Instance on aws to run a t2 micro .exe program with js.nodes on mongoDB pointing to the region on aws and RDP client runs the processes accordingly with api inside .env file etc. = works great
Wanted to make many of these, so:
Instance duplicated by ami=worked
T2 micro RDP client = not exact copy by way of running processes are not exact like the original instance/RDP ….. why?
Had to go into SSM Agent and to get it to stay running went into powerShell and put in your 2 lines of code to add-routes= worked! Thanks,
However 4 other processes are not EXACT like the original Instance running the original RDP client. (They do not stay in the running state after starting them. They become stopped after a few minutes.
(The original RDP version does not do this)
Why is the copy sooooo much different to the point where the actual .exe program in the t2 micro is not even running in the copy version? Is there a way to make an exact copy of the RDP the same way it works with the original instance works with the original RDP?
Your thoughts?
Thank you.
If some processes are not working properly you can try to run them at startup using for example “User data scripts”
Here you will find more information: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-user-data.html
Comments are closed.