Monday, June 8, 2015

SSH Access Denied and SFTP connection closed Fedora

After having my Fedora 21 messed enough that it wasn't worth fixing, I decided to install new shiny Fedora 22 LXDE spin. Installation went (almost) good. And you will see why I say almost.

Upon finishing installation and enabling ssh server with

systemctl start sshd
systemctl enable sshd

I tried to login from my other computer. After asking for password it would simply return Access Denied. Using verbose mode didn't help me much. With my first google search I came upon this problem with guy who was asking help simply saying that he solved his problem by changing his password. 
I know my password, I just typed it in to log onto my system, and I have saved profile on second computer so I don't even need to type it. (yes, I know it's a security hole).
I never had pleasure to meet with ssh setup so I assumed that there is something in sshd_config that I didn't set correctly. So, instead of going through all settings I just copied sshd_config from co-worker's computer, because it works there.
No go. Another 20 minutes of going through every single line inside config file, no go.
Eventually i thought "hmm, maybe I should try changing the password"...
And I kid you not, it was the solution. I even typed in same exact password and this time it worked.

Now just to restore some files I previously backed up, over sftp, I'm too lazy to copy it over usb drive.
sftp username@hostname...
insert password
Connection Closed
Goddamit!

Let's browse Google some more. Most people were having trouble with key login, but almost nobody with password.

sftp -v myusername@myhost
And there it was
debug1: Exit code 127

To make story short, when I copied sshd_config file from another computer I didn't consider that it was Slackware. In most cases that wouldn't matter, but in mine it did because in sshd_config there is line

Subsystem sftp /usr/libexec/sftp-server

But on my system, location of sftp server was

/usr/libexec/openssh/sftp-server

After changing that line in config file and systemctl restart sshd it worked.

No comments:

Post a Comment