fioan89 / sourcesync

A powerful plugin for performing one-way file synchronization for Intellij Idea and Pycharm projects
Other
89 stars 36 forks source link

Error "invalid private key" #76

Closed Apollon77 closed 1 year ago

Apollon77 commented 2 years ago

I get the error that the private key is invalid

com.jcraft.jsch.JSchException: invalid privatekey: [B@1a9104

Is there any special format required?

I use this provate key any day with ssh commands and such.. so it is valid in general.

it looks like

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABDClvRr7V
z+D80UpubEau0TAAAAEAAAAAEAAAEXAAAAB3NzaC1yc2EAAAADAQABAAABAQDrUHYk5Ovo
GLb/lwdcteD6h5VjspJqkTksAf0dCzjrWYwx1w3WPrzB6zIf44Qj8P/hLNGuWtkINzLzyf
...
...
xEXryuf2nR8Vs6NEvr0bMZifxNu2024NOYk/yPqB8kPQUi2kkH5Cs8bilb5Z98TMmGqOF6
gO4hMhgQ==
-----END OPENSSH PRIVATE KEY-----

PS: The name is containing "rsa" and not "dsa" as your example ... might this also be a reason? ... Hm seems not because your screenshot also shows an rsa key

fioan89 commented 1 year ago

@Apollon77 was this working in previous versions of the plugin? According to https://stackoverflow.com/questions/53134212/invalid-privatekey-when-using-jsch the new openssh format was never supported by JSCH. I'll try to upgrade the library to this fork https://github.com/mwiede/jsch/ which seems to be maintained. The official JSCh library is no longer maintained, apparently.

Apollon77 commented 1 year ago

Yes it was working interestingly enough. If ypou have something to test just poke me. WOuld be awesome because helps on special development tasks a lot

fioan89 commented 1 year ago

@Apollon77 can you try this build?

sourcesync-2.0.2-alpha.zip

Apollon77 commented 1 year ago

Wow that seems to work ... I'm wondering because he includes the "project name" also in the target path and not use just the "path inside of the project", but I could adjust that path on the host ....

fioan89 commented 1 year ago

Can you give an explicit example? It might be a regression.

Apollon77 commented 1 year ago

Sure, y project looks like this ...

Bildschirm­foto 2022-12-06 um 00 33 48

And the config like this:

Bildschirm­foto 2022-12-06 um 00 34 47

my server is using that given base directory as base ...

The error I now get is

Bildschirm­foto 2022-12-06 um 00 35 58

So the plugin is adding the "project name" "ioBrokerJs" to the path ... The structure on my server is "/opt/iobroker/iobroker-data/javascript/Anwesenheit/..."

(In fact ... honestly ... when I think then it migtj be that really it was another plugin in the past that I used and your one is the "only" available replacement with SCP" :-) So it might be more a feature request (then I'm sorry and will add a new feature request ticket - or I simply change the structure on the host)

fioan89 commented 1 year ago

Sourcesync was always supposed to upload in base + project name + project tree structure. And the reason behind this approach is that connections have to be reusable between multiple projects. I think it does not makes sense to force users to create a new connection per project just with a base path changed.

Also, if possible, please use sftp, scp connections have some issues when uploading from Windows to a Linux station. Path separators are not translated correctly.

Apollon77 commented 1 year ago

Thank you. Then I adjust my path. All fine.

And I do not want to enable sftp on my servers and thats why I prefer scp (and no issue with my macOS to Linux ;-) ) thank you very much. So the version works fine for me

fioan89 commented 1 year ago

Yeah Unix to Unix should work fine. SFTP is actually just an SSH session. Most Linux machines can be accessed through SSH. SCP uses SSH for data transfer, and uses the same authentication and provides the same security as SSH. Do you have other concerns for not enabling the ssh server, other than security?

I'm just trying to figure out what are the most used features in sourcesync, and why and how are they used. In the future I plan to trim down some of the stuff, like ftp support, it's too much of a burden lately (at least on the testing side) and I don't think many people use anything else than ssh&scp. For me SSH was always a priority, but I might shift my focus on SCP as well.

Apollon77 commented 1 year ago

yes SSH/SCP is "samish" for me becuase it is in fact the same.FTP and SFTP is always something special that you also need to install and I do not need it else ... SSH is always there. Also I remember that FTP/SFTP is supported by Webstorm natively in the meantime, right? They have an open issue for SSH/SCP since years, so here your plugin is life saver :-) (But thats "just my pov")

fioan89 commented 1 year ago

ooh I ought to just name the connection type SSH. Seems like many people confuse SFTP with FTPS. SFTP is the protocol for file transfer, access and management over SSH, while FTPS is a "more secure" version of FTP. SCP is just for transfering, it is also the reason why you have to create the full project structure in the remote because SCP can't do that by itself. SFTP on the other hand is much more complex and can do that automatically. You just have to configure a connection, with a base path and the upload will create the tree structure.

fioan89 commented 1 year ago

They have an open issue for SSH/SCP since years

Can you provide a link? :)

Apollon77 commented 1 year ago

e.g. https://youtrack.jetbrains.com/issue/WI-16202/File-deployment-support-SCP

fioan89 commented 1 year ago

Ohh thx: Seems like not all ssh-servers support sftp:

One more reason is that dropbear (lightweight SSH server used in embedded systems everywhere) doesn't support SFTP, but does - SCP.