You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ansible报错“Failed to connect to the host via scp: scp: Connection closed”求助

Ansible v2.12.10跨平台迁移后SCP连接异常排查请求

问题详情

  • 环境背景:在Windows机器上创建的Python虚拟环境,迁移到MacBook后使用Ansible v2.12.10执行任务
  • 执行任务时出现如下连接失败报错:
PLAY [Provision all hosts] ************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
fatal: [jumper.YYY.systems]: UNREACHABLE! => changed=false 
  msg: |-
    Failed to connect to the host via scp: scp: Connection closed
  unreachable: true
fatal: [cloud.YYY.systems]: UNREACHABLE! => changed=false 
  msg: |-
    Failed to connect to the host via scp: scp: Connection closed
  unreachable: true
  • 已知排查信息:
    • 相同配置在Windows机器上可正常运行
    • 注释掉ansible.cfg中的scp_if_ssh = True后,MacBook上任务可正常执行,但业务需要启用该配置
    • 此前遇到过类似问题,升级到Ansible v2.12及以上版本曾解决,但当前版本下问题复现

当前ansible.cfg配置

[defaults]
nocows = 1
vault_password_file = ./.vault_pass
ansible_managed = Ansible managed - keep your paws off! {file} last modified by {uid}
remote_user = root
host_key_checking = False
retry_files_enabled = False
stdout_callback = yaml
collections_paths = ./
library = ./
roles_path = roles/
# Keep mitogen in mind https://github.com/mitogen-hq/mitogen
# Actually not working with newer ansible releases
#strategy_plugins = mitogen/mitogen-0.3.3/ansible_mitogen/plugins/strategy/
#strategy = mitogen_linear
[ssh_connection]
scp_if_ssh = True
ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s

内容的提问来源于stack exchange,提问作者en1cc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 16:10:01