olav-st / screencloud

Screenshot sharing application for Windows, Mac and Linux.
http://screencloud.net
GNU General Public License v2.0
638 stars 109 forks source link

OS X – Unable to parse RSA private key #89

Closed jwflory closed 1 month ago

jwflory commented 10 years ago

I recently installed ScreenCloud to my OS X iMac running 10.9.4.

I use RSA key authentication on my private server, which I planned to use with ScreenCloud. However, whenever I add my RSA private key from ~/.ssh/id_rsa and attempt to upload a screenshot, ScreenCloud is unable to parse my RSA private key. See screenshot below: f7985f7a51edaa5c8f260dab7406c1ed Alternatively, I have tried converting my RSA key to a .txt and .key file, but that had no effect. I'm not sure how I can get ScreenCloud to recognize my RSA private key.

Any help would be appreciated. Thanks.

olav-st commented 10 years ago

Not sure why it fails, is your key using DSS instead of RSA?

jwflory commented 10 years ago

@olav-st The key is definitely RSA. I use the same key for authentication with my servers. I generated it with the ssh-keygen command on OS X.

olav-st commented 10 years ago

Try entering this in the debug console (go to Preferences and hit Ctrl+D or Command+D) and see what output you get:

import paramiko
paramiko.RSAKey.from_private_key_file("~/.ssh/id_rsa")
jwflory commented 10 years ago

@olav-st: As requested, here is the result.

py> paramiko.RSAKey.from_private_key_file("~/.ssh/id_rsa")
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/pkey.py", line 198, in from_private_key_file
    key = cls(filename=filename, password=password)
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/rsakey.py", line 51, in __init__
    self._from_private_key_file(filename, password)
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/rsakey.py", line 163, in _from_private_key_file
    data = self._read_private_key_file('RSA', filename, password)
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/pkey.py", line 279, in _read_private_key_file
    f = open(filename, 'r')
IOError: [Errno 2] No such file or directory: '~/.ssh/id_rsa'

The file definitely exists, though… screen shot 2014-07-27 at 3 24 58 pm

olav-st commented 10 years ago

Try using the absolute path (without the ~)

jwflory commented 10 years ago

@olav-st: Output below. Also, I do not use a passphrase with my private key.

py> paramiko.RSAKey.from_private_key_file("/Users/justinflory/.ssh/id_rsa")
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/pkey.py", line 198, in from_private_key_file
    key = cls(filename=filename, password=password)
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/rsakey.py", line 51, in __init__
    self._from_private_key_file(filename, password)
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/rsakey.py", line 163, in _from_private_key_file
    data = self._read_private_key_file('RSA', filename, password)
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/pkey.py", line 280, in _read_private_key_file
    data = self._read_private_key(tag, f, password)
  File "/Users/justinflory/Library/Application Support/screencloud/ScreenCloud/plugins/sftp/modules/paramiko/pkey.py", line 323, in _read_private_key
    raise PasswordRequiredException('Private key file is encrypted')
paramiko.PasswordRequiredException: Private key file is encrypted
olav-st commented 10 years ago

Strange... Maybe your private key is encrypted, but ssh gets the password from the OS X keychain?

jwflory commented 10 years ago

@olav-st: If I open up the private key in a program like TextEdit, I can view it fine, if that helps any.

olav-st commented 10 years ago

Does it say "ENCRYPTED" at the start of the file? http://serverfault.com/questions/52732/find-out-if-a-ssh-private-key-requires-a-password

jwflory commented 10 years ago

@olav-st: This is one of the lines in the file, but outside of this, there are no other mentions of encryption.

Proc-Type: 4,ENCRYPTED
odensc commented 10 years ago

I just had this problem, for me I had to convert my private key to a PEM file and use that.

jwflory commented 10 years ago

@thesbros - how did you end up doing that?

odensc commented 10 years ago

@jflory7 openssl rsa -in ~/.ssh/id_rsa -outform PEM -out ./id_rsa.pem

jwflory commented 10 years ago

@thesbros Doesn't seem to be working for me. It prompts me for a passphrase that I don't have, and then if I type something in, it gives an error.

$ openssl rsa -in id_rsa -outform PEM -out ./id_rsa.pem
Enter pass phrase for id_rsa:
12201:error:28069065:lib(40):UI_set_result:result too small:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/ui/ui_lib.c:850:You must type in 4 to 1023 characters
Enter pass phrase for id_rsa:
unable to load Private Key
12201:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/evp/evp_enc.c:330:
12201:error:0906A065:PEM routines:PEM_do_header:bad decrypt:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/pem/pem_lib.c:428:
odensc commented 10 years ago

@jflory7 Try just not typing anything in and hitting enter / return.

jwflory commented 10 years ago

@thesbros That's what I did the first time, and I had the first error listed.

12201:error:28069065:lib(40):UI_set_result:result too small:/SourceCache/OpenSSL098/OpenSSL098-50/src/crypto/ui/ui_lib.c:850:You must type in 4 to 1023 characters

ElijahLynn commented 9 years ago

I am also getting "unable to parse key file", on Ubuntu 14.04 and SC 1.1.6. I will try some of the above recommendations.

ElijahLynn commented 9 years ago

Okay, the issue was that my keyfile has a passphrase and I just haven't used it in so long I forgot about it. Converting to the PEM file requires a passphrase and then strips out the passphrase. So just set the passphrase in the SC settings and it connects then.

ElijahLynn commented 9 years ago

The error message could be improved a bit. If possible to determine if it is a bad passphrase then reflect that in the error message instead of the parse error but if not then just say "unable to parse key file OR bad passphrase".

github-actions[bot] commented 5 months ago

This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed after 30 days.

ElijahLynn commented 5 months ago

bot: still an issue I believe.

github-actions[bot] commented 2 months ago

This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed after 30 days.

github-actions[bot] commented 1 month ago

This issue was closed because of inactivity. If this issue is still relevant, please re-open a new issue.