简体   繁体   English

通过 AWS CLI 中的 aws ssm start session 记录后传递命令

[英]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 通过 AWS CLI 登录,我需要传递“sudo su - <用户>”命令吗?

aws ssm start-session --target "instance ID"??????? aws ssm start-session --target“实例ID”?????? "sudo su - < user >" “sudo su - <用户>”

Is there any way?有什么办法吗? Passing as parameters or something?作为参数传递还是什么?

It is possible to get into an EC2 instance from the command line without SSH.在没有 SSH 的情况下,可以从命令行进入 EC2 实例。 Whenever you can avoid using SSH, and use more cloud-native approaches such as System Manager's Session Manager, that is recommended.只要您可以避免使用 SSH,而是使用更多云原生方法,例如 System Manager 的 Session 管理器,就推荐使用。

The documentation says: 文档说:

Example 1: To start a Session Manager session示例 1:启动 Session 管理器 session

This start-session example establishes a connection with an instance for a Session Manager session.此启动会话示例与 Session 管理器 session 的实例建立连接。 Note that this interactive command requires the Session Manager plugin to be installed on the client machine making the call.请注意,此交互式命令需要在进行调用的客户端计算机上安装 Session 管理器插件。

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

Output: Output:

 Starting session with SessionId: Jane-Roe-07a16060613c408b5

So you can get into your EC2 instance that way, and then enter "sudo su - < user >" .因此,您可以通过这种方式进入您的 EC2 实例,然后输入"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:但是,当前不支持使用aws ssm start-session AWS CLI 命令传入参数,正如同一文档页面所述:

--parameters (map) --参数(地图)

Reserved for future use.保留供将来使用。

key -> (string)键->(字符串)

value -> (list)值->(列表)

(string) (细绳)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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