I want to start an AWS SSM session to an EC2 Amazon linux machine. In my AWS Systems Manager preferences I have set RunAs
user as ubuntu
so basically I am looking for a command which would let me start a session with a different RunAs
user.
Something like this:
aws ssm start-session --target i-id --RunAs ec2-user
Current error message which I get on executing:
aws ssm start-session --target i-id
----------ERROR-------
Unable to start command: failed to start pty since RunAs user ubuntu does not exist
Found this on the AWS Knowledge center article, this might help you.
https://aws.amazon.com/premiumsupport/knowledge-center/ssm-session-manager-connect-fail/
RunAs user name is not valid Error: "Invalid RunAs username"
-or-
Error: "Unable to start shell: failed to start pty since RunAs user xyz does not exist"
Session Manager fails if Enable Run As support for Linux instances is blank or specifies an operating system user name that isn't valid.
To fix this issue, you can provide a valid operating system user name (for example, ubuntu, ec2-user, or centos). Then, verify that the IAM user or role that starts the session is tagged with SSMSessionRunAs = os-user-account-name. The user account must also exist on the operating system. For more information, see Enable run as support for Linux and macOS instances.
Or, you can clear Enable Run As support for Linux instances.