ParallelSSH / parallel-ssh

Asynchronous parallel SSH client library.
https://parallel-ssh.org
GNU Lesser General Public License v2.1
1.2k stars 148 forks source link

request: support private keys which are base64 (or openssh private key data) #317

Closed wfleurant closed 2 years ago

wfleurant commented 3 years ago

Feature request alleviates having to provide a private key file to pssh client if i could provide a base64 value of the private key to ParallelSSHClient (pkey= and proxy_pkey=)
then I can keep privatekeys in ram, versus copying them from ram to disk.

Describe the solution you'd like there is a section here https://ssh-python.readthedocs.io/en/latest/key.html
and in it, references the current way keys are loaded by file. so i think i would like to do something where the above key document includes base64, as in
ssh.key.import_privkey_base64(bytes b64_key, passphrase=b'')

from ssh import key
my_key = key.import_privkey_base64(httpx_get('https://priv8.key'))
client = ParallelSSHClient(hosts, pkey=my_key)

Alternatives . run ssh agent and add keys, but this does not scale with many keys.
. copy keys to tmpfs (ram) with a unique name, then run commands and then destroy keys.

Context/Setup . using multi-thread execution (huey)

pkittenis commented 3 years ago

Thanks for the interest and report.

Yes, I agree this is good to have. Had been considering this feature, good to track it. It is now supported by both ssh2-python and ssh-python.

pkittenis commented 2 years ago

This is planned for next release - 2.8.0.

pkittenis commented 2 years ago

2.8.0 now supports pkey as bytes for private key data.

pkey_data = b"""----BEGIN RSA PRIVATE KEY-----
<some data>
-----END RSA PRIVATE KEY-----
"""
client = <any client>(pkey=pkey_data)