st2 icon indicating copy to clipboard operation
st2 copied to clipboard

No such file or directory: '/home/stanley/.ssh/stanley_rsa

Open doing-cr7 opened this issue 1 year ago • 6 comments

i got a error when i run core.remote

st2 run core.remote hosts='10.69.10.1:5000' cmd='echo123'
.
id: 65ae14e509204db1549f4a31
action.ref: core.remote
context.user: st2admin
parameters:
  cmd: echo123
  hosts: 10.69.10.1:5000
status: failed
start_timestamp: Mon, 22 Jan 2024 07:10:29 UTC
end_timestamp: Mon, 22 Jan 2024 07:10:29 UTC
result:
  error: "Unable to connect to any one of the hosts: ['10.69.10.1:5000'].

 connect_errors={
  "10.69.10.1": {
    "failed": true,
    "succeeded": false,
    "timeout": false,
    "return_code": 255,
    "stdout": "",
    "stderr": "",
    "error": "Failed connecting to host 10.69.10.1. [Errno 2] No such file or directory: '/home/stanley/.ssh/stanley_rsa'",
    "traceback": "Traceback (most recent call last):\
  File \\"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/parallel_ssh.py\\", line 278, in _connect\
    client.connect()\
  File \\"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/paramiko_ssh.py\\", line 171, in connect\
    self.client = self._connect(host=self.hostname, socket=self.bastion_socket)\
  File \\"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/paramiko_ssh.py\\", line 747, in _connect\
    passphrase_reqd = self._is_key_file_needs_passphrase(self.key_files)\
  File \\"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/paramiko_ssh.py\\", line 841, in _is_key_file_needs_passphrase\
    cls.from_private_key_file(file, password=None)\
  File \\"/opt/stackstorm/st2/lib/python3.8/site-packages/paramiko/pkey.py\\", line 249, in from_private_key_file\
    key = cls(filename=filename, password=password)\
  File \\"/opt/stackstorm/st2/lib/python3.8/site-packages/paramiko/rsakey.py\\", line 64, in __init__\
    self._from_private_key_file(filename, password)\
  File \\"/opt/stackstorm/st2/lib/python3.8/site-packages/paramiko/rsakey.py\\", line 190, in _from_private_key_file\
    data = self._read_private_key_file(\\"RSA\\", filename, password)\
  File \\"/opt/stackstorm/st2/lib/python3.8/site-packages/paramiko/pkey.py\\", line 321, in _read_private_key_file\
    with open(filename, \\"r\\") as f:\
FileNotFoundError: [Errno 2] No such file or directory: '/home/stanley/.ssh/stanley_rsa'\
"
  }
}"
  traceback: "  File "/opt/stackstorm/st2/lib/python3.8/site-packages/st2actions/container/base.py", line 117, in _do_run
    runner.pre_run()
  File "/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/paramiko_ssh_runner.py", line 206, in pre_run
    self._parallel_ssh_client = ParallelSSHClient(**client_kwargs)
  File "/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/parallel_ssh.py", line 90, in __init__
    connect_results = self.connect(raise_on_any_error=raise_on_any_error)
  File "/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/parallel_ssh.py", line 131, in connect
    raise NoHostsConnectedToException(msg)

but i only exec ssh command is ok

ssh 10.69.10.1 -p 5000

i try

cp ~/.ssh/id_rsa  /home/stanley/.ssh/stanley_rsa

again run

st2 run core.remote hosts='10.69.10.1:5000' cmd='echo123'

error don't resolved

doing-cr7 avatar Jan 22 '24 07:01 doing-cr7

Does the user account that is running the StackStorm processes have right to read the key?

mamercad avatar Jan 22 '24 13:01 mamercad

I have the same error, if you are using a different home than /home/stanley:

getent passwd stanley
stanley:x:900:900::/opt/xxxx/xxx/home/stanley:/bin/bash

but core.remote using remote-shell-cmd by default take a bad value. You can overwritte it using private_key= option or setting a symlink in /home to the home.

garadar avatar May 06 '24 16:05 garadar

OMHO, stackstorm should read the $HOME of stanley instead /home/stanley by default

garadar avatar May 06 '24 16:05 garadar

OMHO, stackstorm should read the $HOME of stanley instead /home/stanley by default

I wonder if this would help.

mamercad avatar May 06 '24 17:05 mamercad

indeed it could; I will try Thx

garadar avatar May 07 '24 00:05 garadar

It's 'working' However, the one line command does not work if you create the stanley user with a custom home before the install.

garadar avatar May 17 '24 09:05 garadar