简体   繁体   中英

Passing command once logged through aws ssm start session in AWS CLI

I need to pass "sudo su - < user >" command once i logged though AWS CLI using aws ssm?

aws ssm start-session --target "instance ID"??????? "sudo su - < user >"

Is there any way? Passing as parameters or something?

It is possible to get into an EC2 instance from the command line without SSH. Whenever you can avoid using SSH, and use more cloud-native approaches such as System Manager's Session Manager, that is recommended.

The documentation says:

Example 1: To start a Session Manager session

This start-session example establishes a connection with an instance for a Session Manager session. Note that this interactive command requires the Session Manager plugin to be installed on the client machine making the call.

 aws ssm start-session \ --target "i-1234567890abcdef0"

Output:

 Starting session with SessionId: Jane-Roe-07a16060613c408b5

So you can get into your EC2 instance that way, and then enter "sudo su - < user >" .

However, passing in parameters with the aws ssm start-session AWS CLI command is currently not supported, as that same documentation page says:

--parameters (map)

Reserved for future use.

key -> (string)

value -> (list)

(string)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM