-
-
Notifications
You must be signed in to change notification settings - Fork 961
Description
Hi,
I am working on a project that has renci.sshnet implemented to transferring files between servers using key based authentication.
I generated the keys using the documentation i have found on the internet for OpenSSH and windows as i required RSA keys for the renci.sshnet implementation we have in our project.
I managed to get a working version between my main computer (running windows 10) and my hyper V VM (Windows server 2012) this was using the same type of keys (i used the same process when generating keys in both environments).
I'm getting the above error (permission denied (publickey) when trying to connect to a windows server 2019 using the key based authentication.
The code i am using to connect to the sftpclient is shown below:
var authMethod = new AuthenticationMethod [] { new PrivateKeyAuthenticationMethod(username, new PrivateKeyFile[]{
new PrivateKeyFile(PrivateKeyFile, passPhrase)}) };
var SftpClient = new SftpClient(new ConnectionInfo(host, username, authMethod));
try
{
SftpClient.Connect();
}
catch (Exception ex)
{
throw new Exception("Error connecting to the sftp client");
}
When i checked the eventviewer in the environment i am only getting two entries per attempt to connect to the client, these are:
sshd: Connection closed by authenticating user sftpuser (with a
sshd: Authentication refused.
I am able to use the key using PuTTY and i can access the environment using the username and password i have setup for the key
i have tried to generate different keys multiple times but still no luck.
I have knocked up a dummy application to limit the code this runs through.
Are there any prerequisite's that are required in a new server?
Are there much differences that could affect the connection when doing this on a windows 2019 server?
I am trying to increase the debugging info level to output more info which i have change in the sshd_config file but i am not getting any additional info.
I have created a user account called sftpuser that i am storing the keys in C:\Users\sftpuser.ssh\ - have created an authorized_keys file that is a copy of the public key
I have been researching online but there is not much information out there
Any advice on this issue would be greatly appreciated?
I can upload a copy of my sshd_config file if this is required