stensmo/SFTPClient.jl

Private/public key are NULL for a defined path

Closed this issue · 4 comments

I'm trying the library in Windows 10, and when I defined a path for the private and public key I can not connect to the server.
The code is the following:

using SFTPClient
sftp = SFTP("sftp://$ip", "root", "test.pub" , "test.pem")
sftp.verbose = true
files=readdir(sftp) 

from the debug info the keys have the value NULL:

  • SSH MD5 public key: NULL
  • SSH SHA256 public key: NULL

Sorry for the late reply. Can you please paste the debug info here? test.pub and test.pem should be in your current working directory. Otherwise specifying the full path should also work.

Most of the testing is done on Windows 10.

Also check the trouble shooting guide: https://stensmo.github.io/SFTPClient.jl/stable/troubleshooting/

Hi stensmo the debug output is the following, personal information was replaced by "x":

* WARNING: failed to open cookie file ""
*   Trying x.x.x.x:22...
* Connected to x.x.x.x (x.x.x.x) port 22
* Found host x.x.x.x in C:\x\.ssh\known_hosts
* Set "rsa-sha2-256,rsa-sha2-512,ssh-rsa" as SSH hostkey type
* SSH MD5 public key: NULL
* SSH SHA256 public key: NULL
* SSH host check: 0, key: x.x.x.x
* SSH authentication methods available: publickey,password
* Using SSH public key file 'C:\test.pub'
* Using SSH private key file 'C:\test.pem'
* SSH public key authentication failed: Invalid key data, not base64 encoded
* Failure connecting to agent
* Authentication failure
* Closing connection

Your key needs to be formatted in Base64
Example:
-----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBAKj34GkxFhD90vcNLYLInFEX6Ppy1tPf9Cnzj4p4WGeKLs1Pt8Qu
KUpRKfFLfRYC9AIKjbJTWit+CqvjWYzvQwECAwEAAQJAIJLixBy2qpFoS4DSmoEm
o3qGy0t6z09AIJtH+5OeRV1be+N4cDYJKffGzDa88vQENZiRm0GRq6a+HPGQMd2k
TQIhAKMSvzIBnni7ot/OSie2TmJLY4SwTQAevXysE2RbFDYdAiEBCUEaRQnMnbp7
9mxDXDf6AU0cN/RPBjb9qSHDcWZHGzUCIG2Es59z8ugGrDY+pxLQnwfotadxd+Uy
v/Ow5T0q5gIJAiEAyS4RaI9YG8EWx/2w0T67ZUVAw8eOMB6BIUg0Xcu+3okCIBOs
/5OiPgoTdSy7bcF9IGpSE8ZgGKzgYQVZeN97YE00
-----END RSA PRIVATE KEY-----

Hi there, it seems like it was an issue with the new line characters on the public/private key file. Thank you for the support