I am trying to connect to an sftp using private key.

The result is "Server refused our key" (tried it with filezilla and winscp). This is the session log from winscp:

Reading key file "D:\path\to\file\mykey.ppk"
Pageant is running. Requesting keys.
Pageant has 2 SSH-2 keys
Configured key file not in Pageant
Using username "myusername".
Server offered these authentication methods: publickey,gssapi-keyex,gssapi-with-mic,password
Offered public key
Server refused our key
Server refused our key

server /var/log/secure log:

sshd[6219]: Invalid user myusername from xxx.xxx.xxx.xxx
sshd[6220]: input_userauth_request: invalid user myusername

Perhaps it is important to mention that I am using bluehost VPS. The ftp account that I am trying to connect to it is in sub-cpanel account (created through WHM).

Some checks that I did:

I checked and I am able to connect to the same server through ssh using putty and the same private key. So I don't know why is the server refusing the key when trying to connect to it using sftp.

I checked and I was able to connect to the server using normal ftp mode (username+password)


It seems that sftp also works, but to the user account, not to the ftp account (with the private key).

The ftp account was created through cpanel of the sub-cpanel account.

I run sshd in debug mode using "/usr/sbin/sshd -d" and this is the error:

  PAM: password authentication failed for an illegal user: User not known to the underlying authentication module

So I believe that PAM recognize only the user account (for both putty&sftp), but not for the ftp account.

  • This should be a comment, but I don't have the required reputation yet. It is entirely possible, that the SSH server accepts users of a certain group, but the SFTP submodule does not. It would be nice to see your config files; maybe you just denied the access all by yourself. – xwst Dec 11 '16 at 22:51
  • Thanks for the comment. I updated to add some more info, can you check if it helps you understand what I need to do? I will try to upload config file tomorrow, it is already late here – justadev Dec 11 '16 at 23:04
  • Now I am a little confused about what you're trying to achieve. It sounds like you want to login to the SSH server with one of the FTP users. From what you wrote I assume your SSH server is configured to accept system users. Why do you expect it to work with FTP users? In case of SFTP, all the authentication is done by SSH so you don't need a FTP user at all. Am I getting anything wrong? – xwst Dec 12 '16 at 1:27
  • I got it to work. I needed to create a new line in /etc/passwd for the 'ftp user'. thanks for trying to help! – justadev Dec 12 '16 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.