无法打开授权,权限被拒绝

时间:2015-02-02 12:04:22

标签: linux ubuntu ssh

尝试在我的用户上设置SSH登录时出现此错误。

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]

文件权限是:

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

我的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

我已经重启了SSH服务和机器。

我看到这篇文章: SSHD Gives error could not open Authorized Keys, although permissions seem correct

那里给出的答案对我没有帮助。 当我尝试运行restorecon -FRvv ~/.ssh时,我得到:

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

修改

root@(none):~# grep soinfit /etc/passwd
soinfit:x:1001:1001::/:/bin/sh

1 个答案:

答案 0 :(得分:2)

您已将根目录/设置为用户soinfit的主目录,而不是/home/soinfit

编辑用户/etc/passwd的{​​{1}}条目
soinfit

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