SSHパスワードのないルートログインが「許可されていない(公開鍵)」を受信しました。

SSHパスワードのないルートログインが「許可されていない(公開鍵)」を受信しました。

同じLANに2つのRaspberry Pi(Raspbian 7と8を含む)が接続されています。 1つはAPC UPSへのデータ接続です。停電時に実行できる同様のスクリプトが両方のシステムに複数あります。 (UPSに接続されたPiから)私は次のものを持っています/etc/apcupsd/onbattery/etc/apcupsd/offbattery

# [...] 
# after the e-mail stuff

# this is for the remote machine
/usr/bin/ssh -f pi@piac-pal_wired "sh -c '/home/pi/bin/my_script.sh > /dev/null 2>&1'"

# this is for the local machine, connected to the UPS
/home/pi/bin/my_script.sh

ローカルスクリプトは機能しますが、リモートPiのスクリプトは機能しません(エラー:「権限が拒否されました(公開鍵)」)。通常のユーザーとして実行すると、同様にsudoシェルでも機能します。

そのため、rootユーザーが共有キー方式を使用してSSHを介して他のシステムに接続できないことが問題であることを理解しています。

sudo sshコマンドを実行すると、-vv提供されたキーがのキーであることがわかります/root/.ssh/id_rsa。その公開鍵がroot/.ssh/authorized_keysリモートコンピュータに追加され、その/etc/ssh/sshd_config設定には次のものが含まれます。

RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
PermitRootLogin without-password

上記の最後の2行を変更した場合:

PasswordAuthentication yes
PermitRootLogin yes

UPSに接続されているPiのrootユーザーはリモートPiにログインできますが、コマンドにはパスワードが必要です。apcupsdスクリプトが無人で実行されている場合はパスワードを入力できません。

どんな提案でも大歓迎です。ありがとうございます。

ssh -vvv編集:提案されているようにコマンド出力を追加しました。関連部分が最後にあると思います。

debug3: load_hostkeys: loaded 1 keys
debug1: Host '$HOSTNAME' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:7
debug1: ssh_ecdsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /root/.ssh/id_rsa (0x7f8c72a8)
debug2: key: /root/.ssh/id_dsa ((nil))
debug2: key: /root/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_dsa
debug3: no such identity: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug3: no such identity: /root/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

ベストアンサー1

問題は、sshコマンドがpiユーザーではなくユーザーを呼び出すため、ユーザーではなくユーザーがroot確認されていることです。私がしなければならないことは、クライアントのルートキーをサーバーの 。authorized_keys/home/pi/.ssh/root/.ssh/home/pi/.ssh/authorized_keys

おすすめ記事