Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » HowTO use Core/SSH with PRIV/PUB Keys ?
HowTO use Core/SSH with PRIV/PUB Keys ? [message #60709] Fri, 26 July 2024 17:53 Go to next message
omari is currently offline  omari
Messages: 276
Registered: March 2010
Experienced Member
Hi,
I want to connect to server that accept only private key authentification.

I can connect using command line :
ssh -i ./id_rsa user@ServerIP


but with Core/SSH, i have tryed without success.
SshSession session;

String priv = "C:\Users\user\.ssh\id_rsa";
String pub = "C:\Users\user\.ssh\id_rsa.pub";



session.HostBasedAuth().Keys(priv, pub, "", true ).Connect("ssh://user@ServerIP");


session.GetErrorDesc() return "Invalid signature for supplied public key, or bad username/public key combination"



session.PublicKeyAuth().Keys(priv, pub, "", true ).Connect("ssh://user@ServerIP");


session.GetErrorDesc() return "Username/PublicKey combination invalid"


regards
omari.
Re: HowTO use Core/SSH with PRIV/PUB Keys ? [message #60710 is a reply to message #60709] Sat, 27 July 2024 08:58 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1211
Registered: August 2007
Senior Contributor
Hi omari,
Quote:
Hi,
I want to connect to server that accept only private key authentification.

I can connect using command line :

ssh -i ./id_rsa user@ServerIP



but with Core/SSH, i have tryed without success.

SshSession session;

String priv = "C:\Users\user\.ssh\id_rsa";
String pub = "C:\Users\user\.ssh\id_rsa.pub";



session.HostBasedAuth().Keys(priv, pub, "", true ).Connect("ssh://user@ServerIP");



session.GetErrorDesc() return "Invalid signature for supplied public key, or bad username/public key combination"



session.PublicKeyAuth().Keys(priv, pub, "", true ).Connect("ssh://user@ServerIP");



session.GetErrorDesc() return "Username/PublicKey combination invalid"


libssh2 can compute public key from private key, but it wasn't enabled in Upp::SSH package (till now). I have pushed the patches to my fork of the latest upp.


If you could check and confirm that it works, I'll make a pull request and patch the code in Upp main branch.

(All you need to do is pass an empty or null String as public key.)

Best regards,
Oblivion


Re: HowTO use Core/SSH with PRIV/PUB Keys ? [message #60711 is a reply to message #60710] Sun, 28 July 2024 01:38 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 276
Registered: March 2010
Experienced Member
Hi Oblivion.

I have tested your change, but it does not work. it show the same error message.

I think this is a limitation of our libssh2 version 1.10.

support for RSA is enhanced in 1.11 version.

https://github.com/libssh2/libssh2/releases

then i wait for libssh2 upgrade to 1.11 version.

for now, i can use LocalProcess and ssh.exe as external process.

Thanks Oblivion.


regards
omari.
Re: HowTO use Core/SSH with PRIV/PUB Keys ? [message #60713 is a reply to message #60711] Mon, 29 July 2024 08:22 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 276
Registered: March 2010
Experienced Member
Hi,
i have successfully connected using ed25519 private key.

ssh-keygen -t ed25519 -f mykey_ed25519

this confirm that the problem concern only RSA.
after further search i found that:
- libssh2 <= 1.10 use RSA_SHA1 as signing algorithm.
- RSA_SHA1 is unsecure and depracted then default to rejected by ssh servers.
- this is fixed in 1.11 version (i hope):
Adds RSA-SHA2 key upgrading to OpenSSL, WinCNG, mbedTLS, OS400 backends 


regards
omari.
Re: HowTO use Core/SSH with PRIV/PUB Keys ? [message #60716 is a reply to message #60713] Mon, 29 July 2024 11:52 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1211
Registered: August 2007
Senior Contributor
Hello Omari
Quote:
after further search i found that:
- libssh2 <= 1.10 use RSA_SHA1 as signing algorithm.
- RSA_SHA1 is unsecure and depracted then default to rejected by ssh servers.
- this is fixed in 1.11 version (i hope):


Nice to know that it worked for you!

FYI, libssh2 1.11.0 introduced some bugs (a few of them are serious) and regressions (They did a massive cleanup and they are still cleaning up the older and unsafe code, so it was somewhat expected.).
I am going to update the underlying libssh2 library in SSH package to v1.11, once the 1.11.1 becomes official (It is around the corner).


Thank you for your patience.

Best regards,
Oblivion


[Updated on: Mon, 29 July 2024 11:54]

Report message to a moderator

Previous Topic: plugin/sqlite3 does not compile because of Link<> change
Next Topic: Copy the content of a SortedVectorMap
Goto Forum:
  


Current Time: Wed Jun 11 14:44:08 CEST 2025

Total time taken to generate the page: 0.04509 seconds