Archived Forum Post

Index of archived forum posts

Question:

Password & public key authentication for login into a SFTP server?

Sep 11 '17 at 19:09

I’m trying to code in VB.NET both a password & public key authentication for login into a SFTP server.

I tried following this example, but it did not work. My public key is encrypted from the customer.

It seems this example uses a private key, which I do not have, so I’m confused on how to do it.

https://www.example-code.com/vbnet/sftp_pubkeyAuthentication.asp

How do I accomplish this task?


Answer

The term "public key authentication" means that you (the client side) uses the private key, which only you have and thus it's like a password, while the public key is installed on a server. This is how it works with SSH public key authentication. The owner of the key is free to hand out his public key to any number of servers, where it can be installed under his user account. Given that you're the only holder of the private key, only you can authenticate.

If you have an encrypted key, then it must be that you have the private key. There aren't really any formats that encrypt a public key because there's no need to encrypt a public key.

If you truly need password & public key authentication, then you would call AuthenticatePwPk, where you pass both a password and a private key. The AuthenticatePk method is where only a private key is needed for authentication. (Likewise, AuthenticatePw is where only a password is needed.)