web-dev-qa-db-ja.com

これ以上の認証方法はありません。許可が拒否されました(公開キー)

少し前にルーターの背後にホームネットワークをセットアップし、opensshを使用してラップトップ、妻のネットブック、デスクトップがすべてl/x/ubuntu 12.04を実行しているネットワークにアクセスします。これはしばらくの間完全に機能しました。

ネットブックと他の2からのみアクセスできるようになりましたが、ラップトップとデスクトップの間にはアクセスできません。 id_ *ルートを使用したことがないため、〜/ .sshディレクトリにid_ *ファイルがありません。

私はこのようなフォーラムなどで助言された様々な戦略を試しました。 known_hostsを削除し、PasswordAuthenticationなどの構成ファイルをno、yesに変更してコメントアウトします。どれも機能しません。

私が考えることができる唯一のことは、ラップトップとデスクトップの間にvpnネットワークをセットアップする私の最近の変更が、これら2つのマシン間のsshの動作を混乱させる何かを変えたかもしれないということです。ところで、私はまだvpnを動作させることができていません(このフォーラムの以前の投稿を参照)。

デスクトップ上の/ etc/ssh/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 INFO

# 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 internal-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 yes

Match User sftpuser #group sftponly
ChrootDirectory /media/Backups/ftp
X11Forwarding yes
AllowTcpForwarding yes 
ForceCommand internal-sftp

Ssh -v laptopコマンドの出力:

OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /home/malapradej/.ssh/config
debug1: /home/malapradej/.ssh/config line 1: Applying options for laptop
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.0.2 [192.168.0.2] port 22.
debug1: Connection established.
debug1: identity file /home/malapradej/.ssh/id_rsa type -1
debug1: identity file /home/malapradej/.ssh/id_rsa-cert type -1
debug1: identity file /home/malapradej/.ssh/id_dsa type -1
debug1: identity file /home/malapradej/.ssh/id_dsa-cert type -1
debug1: identity file /home/malapradej/.ssh/id_ecdsa type -1
debug1: identity file /home/malapradej/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 [email protected]
debug1: kex: client->server aes128-ctr hmac-md5 [email protected]
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server Host key: ECDSA 1e:f2:57:81:28:8a:12:d3:7e:2d:04:c2:82:4f:43:72
debug1: Host '192.168.0.2' is known and matches the ECDSA Host key.
debug1: Found key in /home/malapradej/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/malapradej/.ssh/id_rsa
debug1: Trying private key: /home/malapradej/.ssh/id_dsa
debug1: Trying private key: /home/malapradej/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey).
5

助けのためのThnx。それで解決しました。私の許可は、.sshの700に設定する必要がありました。 .ssh /の場合は600、両方のマシンで実行することを確認してください。 .ssh /の所有権も変更します。および.ssh /をルートからユーザーに送信します。そうしないと、ユーザーは構成ファイル内の情報にアクセスできなくなります。

Sudo chmod 700 ~/.ssh/
Sudo chmod 600 ~/.ssh/*
Sudo chown -R User ~/.ssh/
Sudo chgrp -R User ~/.ssh/

userはユーザー名です。これは私のために働いた。

15

また、~/.sshに設定ファイルがなく、PubkeyAuthentication=noエントリがないかどうかを確認します

1
Adriano Rivolli