0

I got this error when trying to set SSH login on my user.

Feb  2 13:56:57 (none) sshd[4075]: debug1: trying public key file //.ssh/authorized_keys
Feb  2 13:56:57 (none) sshd[4075]: debug1: Could not open authorized keys '//.ssh/authorized_keys': Permission denied
Feb  2 13:56:57 (none) sshd[4075]: debug1: restore_uid: 0/0
Feb  2 13:56:57 (none) sshd[4075]: Failed publickey for soinfit from 79.182.124.164 port 52788 ssh2
Feb  2 13:56:57 (none) sshd[4075]: debug3: mm_answer_keyallowed: key 0x7f3d8516faf0 is not allowed
Feb  2 13:56:57 (none) sshd[4075]: debug3: mm_request_send entering: type 22
Feb  2 13:56:57 (none) sshd[4075]: debug2: userauth_pubkey: authenticated 0 pkalg ssh-rsa [preauth]

The files permissions are:

root@(none):/home/soinfit# ls -lah
total 12K
drwx------ 3 soinfit soinfit 4.0K Feb  2 13:30 .
drwxr-xr-x 4 root    root    4.0K Feb  2 12:08 ..
drwx------ 2 soinfit soinfit 4.0K Feb  2 13:36 .ssh

enter image description here

My sshd-config:

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel DEBUG3

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM no

I have done restart to the SSH service and to the machine.

I saw this post: SSHD Gives error could not open Authorized Keys, although permissions seem correct

The answer given there did not helped me. When I try to run restorecon -FRvv ~/.ssh I get:

root@(none):/home/soinfit/.ssh# restorecon -FRvv ~/.ssh
-bash: restorecon: command not found

EDIT

root@(none):~# grep soinfit /etc/passwd
soinfit:x:1001:1001::/:/bin/sh
Community
  • 1
  • 1
dasdasd
  • 1,971
  • 10
  • 45
  • 72

1 Answers1

2

You have set the root directory / as home directory for the user soinfit instead of /home/soinfit.

Edit the entry in /etc/passwd for the user soinfit from

soinfit:x:1001:1001::/:/bin/sh

to

soinfit:x:1001:1001::/home/soinfit:/bin/sh
Sebastian Stigler
  • 6,819
  • 2
  • 29
  • 31
  • @BasileStarynkevitch The directory `.ssh` is located in `/home/soinfit` (see code befor 'EDIT' in OP). The original entry in `/etc/passwd` on the other side implyes that the user `soinfit` has `/` as `$HOME`. Therefor my suggested change of this entry in `/etc/passwd` – Sebastian Stigler Feb 02 '15 at 12:53
  • Now I got another error: Feb 2 15:33:59 (none) sshd[4440]: Failed publickey for soinfit from 79.182.124.164 port 49778 ssh2 Feb 2 15:33:59 (none) sshd[4440]: debug3: mm_answer_keyallowed: key 0x7f8d56455f70 is not allowed – dasdasd Feb 02 '15 at 13:39
  • Looks like the public key from the location you call `ssh soinfit@79.182.124.164` is not in the `/home/soinfit/.ssh/authorized_keys` on your server. – Sebastian Stigler Feb 02 '15 at 13:48
  • The file is there. Im sure about it. – dasdasd Feb 02 '15 at 14:01
  • But is the entry of the `id_rsa.pub` file from the location you starts the ssh connection in the file `/home/soinfit/.ssh/authorized_keys` (it should be a line like: `ssh-rsa AAAAB3[.......]== some_comment`) – Sebastian Stigler Feb 02 '15 at 14:18