login about faq

Hello, I am testing the SSH library works.

Now I am trying to see if I can use public ssh keys to connect to a Linux box. Will the ssh library be able to use the sshpublickey.pub file from a Linux box to connect.

Can I use the following format:

const char * pubKey;

pubKey = key.loadText("sshpublickey.pub");


asked Oct 11 '13 at 14:56

L4367's gravatar image


Please disregard, I just saw an example using public key auth. that's also available.

Thank you

(Oct 14 '13 at 10:04) L4367

You cannot use the public-key with ANY library, nor with PuTTY, nor anything else that implements the SSH protocol. The reason is that "public key authentication" is defined by the SSH protocol in this way: The public key is provided to the SSH server administrator and it is stored on the SSH server. You, the client, are the only one in possession of the private key (which is the equivalent of your password). The client-side of the SSH public-key authentication protocol uses the private key to authenticate.

It's this way because you might give your public key to many different SSH server administrators. You (the client-side) should be the only one in possession of your private key -- nobody else. Therefore, it is only you who has the information necessary to authenticate.


answered Oct 14 '13 at 12:21

chilkat's gravatar image

chilkat ♦♦

Thanks for the clear explanation Chilkat. I now understand how it works.

(Oct 14 '13 at 12:28) L4367

Wanted to mention that you're also correct on Putty, it works in the same manner.. Thanks again

(Oct 14 '13 at 12:31) L4367

you set the public key to the ftp id on the Linux box, You can use only key auth, or key and password auth.

Then use the private key on the client with AuthenticatePk. There is another method to pass both the ssh key and password for the other option.


answered Oct 11 '13 at 16:48

cdlvj130's gravatar image


Thank you cdlvj130, but can I do this from the windows side basically using the publickeyfile.pub file I pulled down from the linux box and stored it on the PC?

(Oct 11 '13 at 16:55) L4367

Ok, Back from trying the sample for the private key which works, but when I try the "public key" instead it does not work.

What I want to do is use this library to access the Linux account with "only" the "public key" and not have use the private key.

Is there an available example showing this? Perhaps, I'm just not understanding how the library is supposed to work.

For instance, between Linux machines A and B I can have a user account with generated ssh private and public keys on system A, and then I can copy the authorized file from system A to system B. Next time I ssh to system B,I do not have to enter a password(assuming that when I generated the keys, I chose not to have the password set -- all security issues aside)

Can I do this with this library?



answered Oct 14 '13 at 12:15

L4367's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Oct 11 '13 at 14:56

Seen: 2,436 times

Last updated: Oct 14 '13 at 12:31

powered by OSQA