Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
"What SSH Key Format Does Pythonista Require? Getting 'not a valid ec private key file' Error"
-
I'm trying to use SSH keys in Pythonista, but I'm encountering an error message that says "not a valid ec private key file." I used the following command to generate my SSH key: ssh-keygen -t rsa -b 2048. What format does Pythonista expect for SSH keys, and how can I resolve this error? I want to make sure my keys are in the right format to work with Pythonista. Any guidance on this, including how to address this error message, would be greatly appreciated!
Thank you in advance!
-
@FloMaster Perhaps this could help you, see https://blog.peddals.com/en/pythonista3_ssh_to_xserver/
I don't have any experience nor knowledge about ssh and perhaps is this advice no more valid. Good luck
-
@cvp unfortunately no I also tried the following on my Windows 10 (python3.10) and it worked. I could see on my Linux server that the user was logged in and logged out again
from paramiko import SSHClient, AutoAddPolicy from paramiko.ssh_exception import AuthenticationException, SSHException client = SSHClient() client.set_missing_host_key_policy(AutoAddPolicy()) try: client.connect('IP', username='florian', key_filename='/path to key‘) # Wenn die Verbindung erfolgreich ist, können Sie hier Ihre Aktionen durchführen. print("Verbindung erfolgreich hergestellt!") except AuthenticationException as auth_err: print(f"Fehler bei der Authentifizierung: {auth_err}") except SSHException as ssh_err: print(f"Fehler bei der SSH-Verbindung: {ssh_err}") except Exception as e: print(f"Allgemeiner Fehler: {e}") finally: # Verbindung schließen, wenn Sie fertig sind client.close()
-
@FloMaster Sorry for you, I can't help, I hope that a skilled forum user will see your topic, unfortunately hidden by a lot of spams, and would be able to help you.
-
@FloMaster I'm also not an expert with SSH, but are you using the full path to the key file? You might try this.
client.connect('IP', username='florian', key_filename=os.path.expanduser('~/path to key'))
Pythonnista uses a very old version of paramiko.
-
@FloMaster as @bosco said, Paramiko version of Pythonista is 1.18.5, see change log, current is 3.3.1, 1.18.5 is from 2018-03-12....
-
@cvp thank you for your help
I tried using Stash and the pip function to install the new paramiko package but unfortunately it doesn't work because there are other packages missing that cannot be installed :(
I think with the current version the SSH key has to be in .pem format then it works. Maybe a developer reads this and can try to integrate a newer version than 1.18.3
-
@FloMaster a part of new Paramiko is written in C, then you couldn't integrate it yourself (@omz could do it 😭).
"Cryptography provides the low-level (C-based) encryption algorithms we need to implement the SSH protocol. It has detailed installation instructions which you should read carefully"