When I log with Putty, Putty close after entering the password. When reading the /var/log/auth.log, it says "refusing non-sftp session". I added a line in /etc/sudoers to have access in WinSCP the other day, but I commented it and reboot but still have the error. So I'm not sure if it is related.

How can I fix this?

Thank you

  • Does the server's /etc/ssh/sshd_config file include a ForceCommand directive? May 1, 2023 at 22:15
  • The account you're logging into: is it configured for SSH access or restricted to only SFTP access?
    – Sotto Voce
    May 1, 2023 at 22:39
  • @steeldriver Ah yes, I see one. I just commented it and restart the ssh service and it worked. Thank you May 1, 2023 at 22:40

1 Answer 1


@steeldriver commented the solution. There was a ForceCommand directive in the /etc/ssh/sshd_config file. After removing it, I restarted the server using sudo service ssh restart and it worked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .