tomerfiliba / plumbum

Plumbum: Shell Combinators
https://plumbum.readthedocs.io
MIT License
2.79k stars 182 forks source link

keyfile is ignored by SshMachine #602

Closed youk closed 6 months ago

youk commented 2 years ago

I can't get ssh with key authentication to work. The keyfile attribute seems to be ignored and the program keeps asking for user password. There's even no difference when I specify invalid path to the key file. There's no quick way to examine the ssh command being used as plumbum doesn't have debug facilities (https://github.com/tomerfiliba/plumbum/issues/474).

The key file is accessible and can be read in the same Python script.

The code is basically with SshMachine('host', user='user', keyfile='./ssh/keyfile') as remote_box:

Environment: Debian 11 Python 3.9.2 OpenSSH 8.4p1 Plumbum 1.7.2

youk commented 1 year ago

The issue is present in 1.8.1 as well.

youk commented 7 months ago

I again got the situation when the specified key was ignored. As it turned out, the cause was that OpenSSH considered permissions on the key file as too open and rejected it, printing the warning and switching to password authentication. The confusion stems from Plumbum not displaying stderr, where OpesSSH prints the warning. I could, at least in theory, redirect stderr to stdout for individual command. But how do I do that when using with SshMachine()? I see no options available.

As for the original report, I cannot replay it and confirm it wasn't caused by permissions on the key file. As such, I am going to close the issue. The key file is not ignored, this is just insufficient error reporting.