AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-443480

P Burke's questions

Martin Hope
P Burke
Asked: 2020-11-28 06:58:56 +0800 CST

ssh 与本地密钥文件链接 - 这应该如何工作?

  • 0

我试图让 ssh 链接通过jump服务器工作到target内部子网上的服务器,所以我可以通过一个命令到达目标服务器。如果我在两跳中到达目标服务器,则 ssh'ing 有效:

local$ ssh -i=jump_rsa ec2@jump
jump$ ssh -i=target_rsa centos@target
target$ 

我想要做的是在一个命令中将这些 ssh 连接链接在一起,仅在本地机器上使用 ssh 私钥,据我所知,这是最安全的解决方案(目前在跳转服务器上有一个私钥)。

但是,我完全没有在一个命令中将这些链接在一起,并且我在尝试调试问题时画了一个空白。这里一个可能的复杂情况是,本地服务器是Ubuntu,跳转服务器是amazon linux,目标服务器是centos7;所以我想知道这是否与它有关?

尝试 1 - 通过命令行

$ ssh -A -t -i jump_rsa [email protected] ssh -A -t -i target_rsa [email protected]
Warning: Identity file target_rsa not accessible: No such file or directory.
ssh: connect to host 10.0.0.214 port 22: No route to host
Connection to 18.134.xx.xx closed.

我已经尝试将密钥文件放在任何地方,并更改权限,这没有任何区别。与 -v

Warning: Identity file target_rsa not accessible: No such file or directory.
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 10.0.0.214 [10.0.0.214] port 22.
debug1: connect to address 10.0.0.214 port 22: No route to host
ssh: connect to host 10.0.0.214 port 22: No route to host
Connection to 18.134.xx.xx closed.

是我想要做的甚至可能有很多例子,但没有一个像我试图做的那样使用两个关键文件引用。

尝试 2 - 通过 .ssh/config 文件和代理命令

# .ssh/config
Host jump
  Hostname 18.134.xx.xx
  User ec2-user
  Port 22
  IdentityFile /home/path/to/jump_rsa
  
Host target
  Hostname 10.0.0.214
  User centos
  IdentityFile /home/path/to/target_rsa
  Port 22
  ProxyCommand ssh -q W %h:%p jump

该命令ssh jump工作正常,可以到达跳转服务器,但ssh target失败如下所示:

$ ssh target -v
OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/peter/.ssh/config
debug1: /home/peter/.ssh/config line 16: Applying options for target
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Executing proxy command: exec ssh -q W 10.0.0.214:22 jump
debug1: identity file /home/path/to/target_rsa type -1
debug1: identity file /home/path/to/target_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
kex_exchange_identification: Connection closed by remote host

我想我在这里遗漏了一些明显的东西,但看不到什么。


更新...

尝试 3 - 通过 -J

尝试了 -J 选项,这更有帮助,并且其中有一些有趣的错误。但还是不行。

$ ssh -J jump target -v
OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/peter/.ssh/config
debug1: /home/peter/.ssh/config line 16: Applying options for target
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Setting implicit ProxyCommand from ProxyJump: ssh -v -W '[%h]:%p' jump
debug1: Executing proxy command: exec ssh -v -W '[10.0.0.214]:22' jump
debug1: identity file /home/path/to/target_rsa type -1
debug1: identity file /home/path/to/target_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/peter/.ssh/config
debug1: /home/peter/.ssh/config line 10: Applying options for jump
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 18.134.xx.xx [18.134.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /home/path/to/jump_rsa type -1
debug1: identity file /home/path/to/jump_rsa_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to 18.134.xx.xx:22 as 'ec2-user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:302ZU2HdNyCd7uk+oGiKxoXKe+7eIYRIFNEFzAt9UJU
debug1: Host '18.134.xx.xx' is known and matches the ECDSA host key.
debug1: Found key in /home/peter/.ssh/known_hosts:31
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/path/to/jump_rsa  explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)


debug1: Next authentication method: publickey
debug1: Trying private key: /home/peter/path/to/jump_rsa
debug1: Authentication succeeded (publickey).
Authenticated to 18.134.xx.xx ([18.134.xx.xx]:22).
debug1: channel_connect_stdio_fwd 10.0.0.214:22
debug1: channel 0: new [stdio-forward]
debug1: getpeername failed: Bad file descriptor
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
channel 0: open failed: connect failed: No route to host
stdio forwarding failed
kex_exchange_identification: Connection closed by remote host
# .ssh/config
Host jump
  Hostname 18.134.xx.xx
  User ec2-user
  Port 22
  IdentityFile /home/path/to/jump_rsa
  
Host target
  Hostname 10.0.0.214
  User centos
  IdentityFile /home/path/to/target_rsa
  Port 22
ssh
  • 2 个回答
  • 1720 Views
Martin Hope
P Burke
Asked: 2020-09-22 08:19:41 +0800 CST

awscli v2 需要 sudo 才能运行,否则获得权限被拒绝错误 ubuntu 20.04.01

  • 2

我已按照此处的官方 AWS 说明安装了 awscli V2 :

$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ unzip awscliv2.zip
$ sudo ./aws/install

安装似乎工作正常,除了我不能在没有 sudo 的情况下使用 aws 命令。

$ sudo aws --version
$ aws-cli/2.0.50 Python/3.7.3 Linux/5.4.0-47-generic exe/x86_64.ubuntu.20

没有须藤...

$ aws --version

Command 'aws' not found, but can be installed with:

sudo snap install aws-cli  # version 1.15.58, or
sudo apt  install awscli   # version 1.18.69-1ubuntu0.20.04.1

See 'snap info aws-cli' for additional versions.

更多详细信息:

$ which aws # displays nothing
$ sudo which aws
/usr/local/bin/aws
$ /usr/local/bin/aws
bash: /usr/local/bin/aws: Permission denied

如果我开始查看链接的去向,它们会变得非常复杂:

$ sudo ls -l /usr/local/bin/aws
lrwxrwxrwx 1 root root 37 Sep 21 16:43 /usr/local/bin/aws -> /usr/local/aws-cli/v2/current/bin/aws

$ sudo ls -l /usr/local/aws-cli/v2/current/bin/aws
lrwxrwxrwx 1 root root 11 Sep 21 16:43 /usr/local/aws-cli/v2/current/bin/aws -> ../dist/aws

$ sudo ls -l /usr/local/aws-cli/v2/2.0.50/dist
total 48400
-rwxr-x--- 1 root root   214121 Sep 21 16:43 array.cpython-37m-x86_64-linux-gnu.so
-rwxr-x--- 1 root root   237647 Sep 21 16:43 _asyncio.cpython-37m-x86_64-linux-gnu.so
-rwxr-x--- 1 root root  4136160 Sep 21 16:43 aws
drwxr-x--- 6 root root     4096 Sep 21 16:43 awscli
-rwxr-x--- 1 root root  4151368 Sep 21 16:43 aws_completer
.
.
.

在最终目录中,执行位似乎已被删除,这可能是问题所在,但这似乎是一个非常根本的问题,但我找不到任何其他关于此问题的报告。

谁能告诉我发生了什么?感谢。

将 o+x 添加到最后一个目录中的 aws 文件并不能解决问题。如果我尝试通过似乎可以正常工作的 apt 安装,但我得到了我不想要的 V1 API。

linux permissions sudo aws-cli
  • 1 个回答
  • 3770 Views
Martin Hope
P Burke
Asked: 2020-01-17 06:20:47 +0800 CST

确定应用程序使用多少 AWS VPC 的标准?VPC 间与 VPC 内流量

  • 0

关于使用一个 VPC 与多个用于应用程序托管的良好实践,我似乎找不到任何具体的指导。该链接涉及该主题,但已经很老了,并没有真正提供答案。

我目前正在将由大约 50 个应用程序和两个数据库场(SQL Server 和 Oracle)组成的传统托管环境迁移到 AWS;总资产约为 250 台 Windows 服务器。目前,每个应用程序基本上都位于其自己的 /24 子网上。

我得到指导,每个应用程序和数据库场都应该位于自己的 AWS 账户和 VPC 中,我不确定这种方法是否明智;尤其是从数据库中分离应用程序的部分。

我不太担心的帐户,因为这更像是一个计费问题。但就 VPC 而言,我试图理解说之间的区别:

  1. 在 1 个 VPC 内复制整个环境,而不是
  2. 引入 50 个 VPC 来托管相同数量的应用程序/服务器。

在(1)和(2)之间做出决定时应该考虑什么,或者在中间做出一些妥协。我查看了 AWS 文档,并没有真正找到关于这个主题的任何明确建议。

在我看来,主要区别在于网络流量都是 VPC 内部与 VPC 之间的流量。这表示:

  • 现在有额外的成本,因为 VPC 间的流量成本和 VPC 内的流量没有。
  • 还有一些额外的复杂性在于需要选择、设置和管理 VPC 间机制(例如对等或中转网关)。

但是以上都不是以一种或另一种方式做事的明确理由;例如,虽然 50 个 VPC 相当多,但所讨论的数字完全在 Peering 的限制范围内。

还有什么我应该考虑的吗?

  • Intra vs. Inter VPC 流量等的性能特征如何?

其他注意事项:

  • 必须跨 VPC 管理 CIDR 块以避免冲突。
  • Peering 的最大 MTU 为 1500 字节
  • 默认情况下,VPC 间流量未加密。
  • DNS 并发症。

谢谢你的帮助。

amazon-web-services
  • 2 个回答
  • 106 Views
Martin Hope
P Burke
Asked: 2019-09-24 04:29:43 +0800 CST

Ansible (V2.8) 细粒度控制将 Playbook 执行限制到节点子集

  • 1

我有一套相当复杂的剧本和导入的角色来构建一个应用程序平台。一切都在一个hosts.ini文件中定义,并且广泛使用组来识别专家服务器角色:Web、数据库、搜索等。

然而,整个平台支持应用程序的两个不同实例,在某些情况下,我需要在四个 Web 节点中的两个之间建立特定的链接。例如,对于下面的主机列表,我想在 app1_node1 和 app1_node2 以及 app2_node1 和 app2_node2 之间设置 gluster 卷。

[web]
app1_node1
app1_node2
app2_node1
app2_node2

并有一个这样做的剧本,但一次只能用于两个节点。因此,如果 hosts 文件还包含以下内容:

[webapp1]
app1_node1
app1_node2

[webapp2]
app2_node1
app2_node2

--limit=webapp1并且使用(或 webapp2)调用剧本,一切正常。

但我不确定一次性构建所有内容的最佳方法。例如,我可以复制 playbook 并在每个中使用不同的 hosts 语句。但这似乎不是一个好主意。

我想出的最佳解决方案是有一个中间剧本启动器,如下所示:

---
- name: PLAYBOOK playbook_launcher.yml
  hosts: webapp1

  tasks:

- name: Include playbook
  import_playbook: theplaybook.yml

- hosts: webapp2

  tasks:

- name: Include playbook
  import_playbook: theplaybook.yml

实际的剧本有更广泛的主机声明。

---
- name: PLAYBOOK theplaybook.yml
  hosts: web

这是最好的方法,还是我在 Ansible 的工作方式中遗漏了一些明显的东西,使这更容易?

ansible
  • 1 个回答
  • 720 Views
Martin Hope
P Burke
Asked: 2019-09-20 05:05:09 +0800 CST

Ansible (2.8) 在一系列剧本/角色开始时收集所有用户名/密码

  • 1

我有一组剧本和角色,它们构建了一个相当复杂的应用程序平台:几个剧本、几个角色和多个清单文件定义了平台的特定变体。在构建期间,我需要输入用户名/密码:数据库帐户,访问 git 以提取代码等。

我想在 ansible-playbook 命令发出后(例如在第一个剧本中)提示所有凭证,所有剧本。在需要时将它们收集到多个剧本中意味着在不同的时间点暂停构建几分钟,所以我宁愿从一开始就一次性获得所有凭据。

我还希望能够在开发 Ansible 剧本或构建简单的测试环境时为凭据提供默认值,并且不需要从密码管理器中剪切和粘贴真实凭据。默认值意味着我可以多次点击返回以接受预定义的默认值并快速进入实际构建某些东西的剧本和角色。

Ansible Vault 是一个选项,但对于我的简单要求来说似乎有些过分,在这种情况下,密码管理器是我组织的正常解决方案,所以如果我引入 Vault,我会复制凭据。

我看过vars_prompts,但这不适合有几个原因,包括:变量的范围只是当前的剧本,所以我以后不能使用它们;并且该group_vars部分不可用,vars_prompt因此我无法根据库存文件中定义的变量控制要求哪些变量。

我查看了该pause模块,它可以访问 group_vars 以及when子句,并set_facts在以后使 vars 可用。下面是一些示例,工作代码,但它非常冗长,需要一个pause任务和两个set_facts收集的每条数据。

但第一个问题真的是,在 Ansible 中是否有更好、更标准的解决方案来解决这个问题?在剧本执行开始时收集所有凭据似乎是一个显而易见的要求,但我似乎无法在任何地方找到解决此问题的标准解决方案。

工作示例,但有没有更好的方法来做到这一点?

  pre_tasks:
  - name: "get username"
    pause:
      prompt: "Enter username [defaultusername]"
    register: username
    run_once: yes
  - name: username after pause command is
    debug:
      msg: "{{username}}"

  - name: set_fact for default username
    set_fact:
      username_fact: "defaultusername"
    when: username.user_input == ""

  - name: set_fact for non-default username
    set_fact:
      username_fact: "{{username.user_input}}"
    when: username.user_input != ""

  - name: username_fact
    debug:
      msg: "username_fact is {{username_fact}} "
ansible
  • 1 个回答
  • 601 Views
Martin Hope
P Burke
Asked: 2019-09-17 04:24:50 +0800 CST

Ansible 变量定义以从库存文件中选择 import_playbook

  • 0

我正在使用 Ansible (V2.8) 构建两个恰好支持 Drupal 的不同服务器环境。它们在 OS、RDBMS、gluster、memcached 等方面的设置非常相似。但在 Drupal 的使用方面(不同版本、不同数量的 drupal 实例等)却非常不同。因此,虽然几乎所有的剧本、var 文件等都很常见,但我有针对 Drupal 的特定于平台的剧本。

我有单独的库存文件,但一个常见的 site.yml 文件只包含一堆 import_playbook: 语句。

我正在努力的是选择正确的 drupal 剧本的最佳方式。

目前我在命令行上使用以下内容: -i /vagrant/inventories/inventory-env1.ini --extra-vars environment_name=env1

这允许以下语句在 site.yml 中工作 - import_playbook: playbooks/drupal/drupal_{{environment_name}}.yml

但这意味着我在同一命令行上指定了两次环境,一次用于选择库存文件,一次用于设置变量。正如我通常发现重言式是糟糕编程的证据,它让我觉得我错过了一种更好的方法来做到这一点。

理想情况下,我只想在清单文件中指定“environment_name”。但我不能,因为它对 site.yml 不可用,原因如下: https ://github.com/ansible/ansible/issues/33659 。

那么,我是否遗漏了什么,或者就是这样?

ansible
  • 2 个回答
  • 1123 Views
Martin Hope
P Burke
Asked: 2019-04-16 02:03:12 +0800 CST

以 root 身份运行或使用 sudoers 文件条目的服务帐户运行之间的区别

  • 0

我有一个早期问题的演变。

主要问题:以 root 身份运行程序与通过具有 sudoers 文件条目的服务帐户运行程序之间有什么有意义的区别?

我必须将第 3 方软件代理部署到具有安全意识的客户的 RHEL 环境中。默认安装导致代理的文件和文件夹归 root 所有,并计划在启动、关闭或通过 crontab 文件运行;但无论哪种方式,它都作为根进程运行,安全团队中似乎没有人喜欢。

供应商建议更安全的替代方法是通过具有 sudoers 文件条目的服务帐户执行代理:例如:

agent-user ALL=NOPASSWD: /opt/agent/agent-executable

但从安全的角度来看,这实际上更好吗?或者在这种情况下最佳做法是什么?

在我看来,无论哪种方式,代理都将获得对服务器的特权访问。服务帐户是一种自定义(虽然由供应商支持)似乎是一个犯错的机会。

是NOPASSWD:一个安全漏洞,并且会规定一个/sbin/nologin提高安全性的外壳?

security
  • 1 个回答
  • 1066 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve