AWS Session Manager未采购bash rc [英] AWS Session Manager is not sourcing bash rc

查看:66
本文介绍了AWS Session Manager未采购bash rc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AWS Systems Manager会话管理器连接到我的EC2实例.

I am using AWS Systems Manager Session Manager to connect to my EC2 instance.

连接后,该会话不会获取我的.bashrc或.bash_profile,因此我得到了一个非常普通的外壳,并且希望在启动时进行一些配置.

When I connect, the session does not source my .bashrc or .bash_profile, so I get a pretty plain shell and would like to setup some configuration when it starts.

会话管理器以ec2-user身份连接我,但外壳程序在/目录而不是用户目录中启动.

The session manager connects me as the ec2-user but the shell starts in the / directory and not the user directory.

我无法确定它在启动时是否在寻找任何配置文件.
如何获取用户配置文件的源代码?

I am unable to figure out if it is sourcing any configuration files when it starts up.
How can I get it to source the users configuration files?

我通过启用以支持方式运行"设置将会话管理器设置为使用ec2-user.

I have set up session manager to use the ec2-user by enabling the "run as support" setting.

如果我使用EC2实例connect连接到实例,则可以正常工作,如下所示:

If I connect to an instance using the EC2 instance connect then it works as you can see here:

但是,如果我使用会话管理器,则不会获得配置文件,如您在此处看到的那样:

However if I use the session manager, the configuration files are not sourced as you can see here:

推荐答案

AWS Systems Manager会话管理器使用代理"与Amazon EC2实例建立连接.代理将实例注册到Systems Manager.请求连接时,将消息发送到代理.然后将命令发送到代理,该代理在本地执行它们并发送回结果.

AWS Systems Manager Session Manager uses an "agent" to establish a connection with the Amazon EC2 instance. The agent registers the instance with Systems Manager. When a connection is requested, a message is sent to the agent. Commands are then sent to the agent, which executes them locally and sends back the results.

因此,会话管理器实际上并未登录到bash会话中.它只是按接收到的命令一次执行一次命令.

Therefore, Session Manager is not actually logged into a bash session. It is simply executing the commands one-at-a-time as received.

会话管理器的好处是它可以用于连接到私有EC2实例,因为该代理建立了到AWS的出站"连接,而不是将连接请求发送到该实例.

The benefit of Session Manager is that it can be used to connect to a private EC2 instance because the agent establishes an 'outbound' connection to AWS, rather than the connection request being sent 'to' the instance.

Amazon EC2实例连接实际上建立了到该实例的普通SSH连接. Web浏览器使用与AWS的Guacamole连接,然后使用普通的SSH(带有额外的黑客工具以允许临时密钥对)运行命令.因此,它看起来像是在外壳上运行的普通连接.

Amazon EC2 Instance Connect, in contrast, actually establishes a normal SSH connection to the instance. The web browser uses a Guacamole connection to AWS, which then uses normal SSH (with an extra hack to permit temporary keypairs) to run the commands. Therefore, it looks like a normal connection running against the shell.

您实际上可以将EC2实例连接的临时SSH密钥"功能与普通SSH客户端一起使用,而无需使用基于Web的SSH客户端.因此,它实际上具有两个功能:一个基于Web的SSH客户端,以及一种使用临时密钥对建立SSH连接的方法.

You can actually use the "temporary SSH keys" feature of EC2 Instance Connect together with a normal SSH client, without using the web-based SSH client. Thus, it's actually two features in one: a web-based SSH client, and a means of using temporary keypairs to establish the SSH connection.

这篇关于AWS Session Manager未采购bash rc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆