web-dev-qa-db-ja.com

chmod 600の後に許可が拒否される(公開鍵)のはなぜですか?

私は得た

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/Cody/.ssh/blue_gum.pub' are too open.

やった

chmod 600 ~/.ssh/blue_gum.pub

そして今、SSHキーのパスワードを入力するためのポップアップ(mac os x mavericksを使用)が表示されますが、パスワードがないので空白のままにして、

Permission denied (publickey).

キーは、を使用してサーバー上のauthroized_keysファイルにコピーされました。

scp ~/.ssh/blue_gum.pub [email protected]:~/.ssh/authorized_keys

サーバーにscpする前にchmod600も試しましたが、同じことが起こります。

クライアントとサーバーの.sshに700のアクセス許可があり、内部のすべてのファイルに600のアクセス許可があることを確認しました。それでも同じ問題です。以下のトラブルシューティング方法を試してみます。また、これがまったく役立つ場合は、私の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 no
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 yes
IgnoreUserKnownHosts no
PasswordAuthentication no
3
cbalos

これは、OpenSSHの最も厄介な点です。これは、エラーメッセージが必然的に不可解であるという事実と混ざり合っており、デバッグは通常のITプラクティスよりもブードゥーに似ています。いずれにせよ:

  1. 両方のサーバー上の.ssh内のすべてのファイルおよびクライアントにアクセス許可600があることを確認してください。

  2. 両方のサーバーおよびクライアントで、ディレクトリ.sshにアクセス許可700があることを確認してください。

問題が解決しない場合は、サーバーでopensshを強制終了し、コマンド(Sudoとして発行される)を使用して再起動します。

   killall sshd && /usr/sbin/sshd -Dd

これにより、サーバーでのデバッグ出力が有効になり、コマンドを使用してクライアントから接続を試みます。

  ssh me@my_remote_machine -vvv

これにより、verbose出力が有効になります。うまくいけば、これら2つの出力の組み合わせにより、問題のトラブルシューティングが可能になるはずです。

2
MariusMatutiae