Using ssh tunnel with public and private keys - WeOnlyDo Discussion board

Using ssh tunnel with public and private keys (wodSSHTunnel)

by Alice Feema, Sunday, April 06, 2014, 13:54 (3665 days ago)

Hello, i am no programmer and i am looking to create a simple tunnel from my PC to my server for simple port forward, and i have to use public and private keys, i have a project to generate the keys, the code i use is:

WODSSHKeyLib.Keys key = new WODSSHKeyLib.Keys();
key.Generate(WODSSHKeyLib.SSHKeyTypes.RSAkey, 1024);
key.PublicKeySave(WODSSHKeyLib.SSHKeyTypes.RSAkey, "public");
key.Save(WODSSHKeyLib.SSHKeyTypes.RSAkey, "private");

this creates 2 files, public and private in the bin directory, and then i have another project with this code:

WODSSHKeyLib.Keys key = new WODSSHKeyLib.Keys();
key.Load("private");
wodSSHTunnel1.Hostname = hostname;
wodSSHTunnel1.Login = "sshuser";
wodSSHTunnel1.Authentication = wodSSHTunnelCOMLib.AuthenticationsEnum.authPubkey;
wodSSHTunnel1.PrivateKey = key;
wodSSHTunnel1.Timeout = 120;
wodSSHTunnel1.Compression = 6;
wodSSHTunnel1.Connect();

on my server i have OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
and i logged in with my sshuser and created a file
vi ~/.ssh/authorized_keys2
and pasted the contents of "public" file created earlier.

but each time i try to use my second project i get
Invalid username or password reported by server, or bad private key.

I tried using putty with keys and it works, i used a tutorial i found online using puttygen.exe

Can you help me?


Complete thread: