Remote execution fails with the error 'Failed to establish connection to remote host, exit code: 255'

Solution Verified - Updated

Environment

  • Red Hat Satellite 6

Issue

  • While running a remote job/command from the Satellite webui, it fails with the following error.

    Error initializing command: RuntimeError - Failed to establish connection to remote host, exit code: 255
    2:
    Exit status: EXCEPTION
    

Resolution

  • Verify if the SSH keys are properly copied to the host in question. To copy the SSH keys from the Satellite CLI, run:

    [root@sat]# ssh-copy-id -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub root@host.example.com
    

    Ensure the Satellite is able to run commands on the host without password.

    [root@sat]# ssh -i ~foreman-proxy/.ssh/id_rsa_foreman_proxy root@host.example.com 'uptime'
    
  • Same error observed while running remote execution as non-root user on RHEL 8.7 and below versions. Try to run the job on RHEL 8.8 client.

  • See if there is any SSH configuration file with wrong permission, /etc/ssh/ssh_config.d/02-rekey-limit.conf as an example. Permission should be 0644 for this file.

  • This issue may also happen if a remote execution user account is not created on the client system. Verify the global params set for the particular client on Hosts -> All Hosts -> Concerned Host -> Edit -> Parameters tab .

For more KB articles/solutions related to Red Hat Satellite 6.x Remote Execution Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Remote Execution Issues

Root Cause

  • SSH keys are not copied on the hosts.
  • Wrong file permission on SSH config files.
  • Actual Remote execution user was missing on the client.

Diagnostic Steps

  • Following error logged when the wrong permissions set to /etc/ssh/ssh_config.d/02-rekey-limit.conf

    **2023-05-12T17:06:00  [D] Can't open user config file /etc/ssh/ssh_config.d/02-rekey-limit.conf: Permission denied**
    2023-05-12T17:06:00  [E] error while initializing command RuntimeError Failed to establish connection to remote host, exit code: 255:
    /usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.7.3/lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb:406:in `ensure_remote_command'
    /usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.7.3/lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb:179:in `establish_connection'
    /usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.7.3/lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb:146:in `start'
    /usr/share/gems/gems/smart_proxy_dynflow-0.8.2/lib/smart_proxy_dynflow/runner/dispatcher.rb:32:in `start_runner'
    /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/actor.rb:13:in `on_message'
    
SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.