AWS 中的另外一种远程工具 AWS Session Manager


作者:SRE运维博客
博客地址:https://www.cnsre.cn/
文章地址:https://www.cnsre.cn/posts/230129126154/
相关话题:https://www.cnsre.cn/tags/aws/


背景需求

因为项目的安全性。为了避免项目的服务器暴露在公网中。很多时候我们会使用跳板机或者是一些三方的远程工具,来进行一些安全性比较高的方式来进行远程项目的服务器,但是往往越安全的方式就越麻烦。那有没有一种既安全,有便捷的连接方式呢?当然有,今天就介绍下AWS Session Manager。

前置需求

{{< alert theme="success" dir="ltr" >}}

  • 一台 EC2 服务器(需要开启 SSM 远程服务并分配权限)
  • 一个 AWS 账户

安装配置 SSM Agent

在 Amazon Linux 2 中安装SSM Agent

x86_64

sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm

ARM64

sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_arm64/amazon-ssm-agent.rpm

在 CentOS 7.x 上安装 SSM Agent

x86_64

sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm

ARM64

sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_arm64/amazon-ssm-agent.rpm

启动服务并设置为开机启动

sudo systemctl status amazon-ssm-agent
sudo systemctl enable amazon-ssm-agent

{{< alert theme="warning" dir="ltr" >}}
如其他系统安装请参考 在适用于 Linux 的 EC2 实例上手动安装 SSM Agent

给 EC2 分配对应权限

角色管理中选择创建角色
如下如图所示选择对应选项。
sre运维|Linux运维|关键词
搜索AmazonSSMFullAccess 选择下一步
sre运维|Linux运维|关键词
填入角色名称,然后创建角色
sre运维|Linux运维|关键词
AWS EC2 控制台中找到对应的服务器,然后点击操作``安全 修改IAM角色
sre运维|Linux运维|关键词
在框内搜索刚才创建的角色名称。然后确定选择。
sre运维|Linux运维|关键词

AWS 中的远程链接方式 Session Manager

安装完以后可以在AWS 中我们可以直接通过控制台去链接 Linux 服务器,如下图。在选中实例以后 在右上角中选择连接。然后再次进行远程登录服务。
sre运维|Linux运维|关键词

sre运维|Linux运维|关键词
{{< alert theme="warning" dir="ltr" >}}
如遇到无法远程的情况请按照下面的方法将安装ssm服务。

在 SSM 中进行远程链接

在控制台 Amazon Systems Manager 中选择 Session Manager
sre运维|Linux运维|关键词
选择启动会话。
sre运维|Linux运维|关键词
选择对应的实例 然后点击启动会话。
sre运维|Linux运维|关键词
然后就进入到了系统界面。
sre运维|Linux运维|关键词

{{< alert theme="success" dir="ltr" >}}
如何通过IAM让不同的 aws 用户拥有不同的远程服务器权限?下篇文章将会介绍 Session Manager 的进阶用法


作者:SRE运维博客
博客地址:https://www.cnsre.cn/
文章地址:https://www.cnsre.cn/posts/230129126154/
相关话题:https://www.cnsre.cn/tags/aws/


posted @ 2023-05-11 12:29  SRE运维博客  阅读(65)  评论(0编辑  收藏  举报