asyncssh.process.ProcessError: Process exited with non-zero exit status 255
The ProcessError 225 confuses me, When I read process 255 existing status means it should not establish an SSH connection at all, could you please improve this
The method async def wait(...) wait for the subprocess to terminate, means the login is a success or not?
My environment is Ubuntu, login test verify using the public key. This issue is very hard to reproduce in my system.
async with asyncssh.connect(
host=hostname,
username=username,
port=port,
client_keys=[private_key],
known_hosts=None,
) as conn:
result = await conn.run("echo $USER && ls -l", check=True)
log.info(result.stdout)
except (OSError, asyncssh.Error) as exc:
log.debug("SSH connection failed using private key: " + str(exc))
raise exc
File "/src/tests/test_ssh/login_test.py", line 316, in main
await test_and_verify_sshd_pod_login(
File "/src/tests/test_ssh/login_test.py", line 202, in test_and_verify_sshd_pod_login
if not await test_ssh_login(
File "/src/tests/test_ssh/login_test.py", line 131, in test_ssh_login
raise exc
File "/src/tests/test_ssh/login_test.py", line 127, in test_ssh_login
result = await conn.run("echo $USER && ls -l", check=True)
File "/usr/local/lib/python3.9/site-packages/asyncssh/connection.py", line 4117, in run
return await process.wait(check, timeout)
File "/usr/local/lib/python3.9/site-packages/asyncssh/process.py", line 1419, in wait
raise ProcessError(self.env, self.command, self.subsystem,
asyncssh.process.ProcessError: Process exited with non-zero exit status 255
If you got far enough for a ProcessError to be returned, that means the call to asyncssh.connect() succeeded, including the authentication. The error you are seeing indicates there was some kind of problem running the command, causing it to return a non-zero exit status, and since you had check=True set, an exception was raised. You can also see this by the fact that the traceback shows you in the run() function on the connection, rather than being still in the connect().
If you want to better distinguish between errors in connect() vs. run(), you could have separate try blocks for each of those, but that won't address the underlying problem here.
An exit code of 255 usually means the remote system attempted to return an exit code of -1. which seems unusual for the command you are running. Can you get any logs from the remote system here? If you try other commands, does it make a difference? What version of SSH is running on the remote system?
The next step would probably be to enable debugging on AsyncSSH and/or the remote system. Adding the following should do this on the AsyncSSH side:
logging.basicConfig()
asyncssh.set_log_level('DEBUG')
asyncssh.set_debug_level(2)
Thanks I will give a try today
Closing due to inactivity. Feel free to reopen this or open a new issue if you need anything else.