質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Raspbian

Raspbianは、DebianベースのRaspberry Pi用ディストリビューション。ハードウェア浮動小数点演算を有効にすることが可能で、Webブラウズなどの速度を向上できます。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

Raspberry Pi

Raspberry Piは、ラズベリーパイ財団が開発した、名刺サイズのLinuxコンピュータです。 学校で基本的なコンピュータ科学の教育を促進することを意図しています。

Q&A

解決済

1回答

1966閲覧

PiServerを用いてネットワークブートをしたRaspberryPiで公開鍵認証によるSSH接続をしたい

vektor

総合スコア6

Raspbian

Raspbianは、DebianベースのRaspberry Pi用ディストリビューション。ハードウェア浮動小数点演算を有効にすることが可能で、Webブラウズなどの速度を向上できます。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

Raspberry Pi

Raspberry Piは、ラズベリーパイ財団が開発した、名刺サイズのLinuxコンピュータです。 学校で基本的なコンピュータ科学の教育を促進することを意図しています。

0グッド

0クリップ

投稿2019/07/29 09:59

編集2019/07/29 10:17

前提・実現したいこと

PiServer(サーバ)を用いてネットワークブートをしたRaspberryPi(クライアント)があり、サーバとクライアント間を公開鍵認証によってSSH接続をしたいと考えています。
パスワードによるSSH接続は出来ているのですが、公開鍵認証によるSSH接続がうまく行えていません。
/var/log/auth.logを見る限り、クライアント側が公開鍵を見に行く際にpermission deniedとなっているようです。
しかし~/.sshと~/.ssh/authorized_keysのパーミッションはそれぞれ「drwx------(700)」、「-rw-------(600)」となっており問題ないと思います。

他に設定したり修正したりする必要のある部分はあるのでしょうか?

各ファイルのパーミッション、クライアント側のログ

LED@raspberrypi:~ $ ls -la .ssh total 24 drwx------ 1 LED LED 4096 Jul 29 15:16 . drwxr-xr-x 1 LED LED 4096 Jul 11 14:41 .. -rw------- 1 LED LED 381 Jul 29 15:19 authorized_keys -rw------- 1 LED LED 1675 Jul 11 14:57 id_rsa -rw------- 1 LED LED 381 Jul 29 15:16 id_rsa.pub -rw-r--r-- 1 LED users 222 Jul 11 14:41 known_hosts

/var/log/auth.log

Jul 29 16:01:47 raspberrypi sshd[447]: debug1: Forked child 707. Jul 29 16:01:47 raspberrypi sshd[707]: debug1: Set /proc/self/oom_score_adj to 0 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: inetd sockets after dupping: 3, 3 Jul 29 16:01:47 raspberrypi sshd[707]: Connection from 192.168.101.253 port 39312 on 192.168.101.159 port 22 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: Client protocol version 2.0; client software version OpenSSH_7.4p1 Debian-10+deb9u6 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: match: OpenSSH_7.4p1 Debian-10+deb9u6 pat OpenSSH* compat 0x04000000 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: Local version string SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u6 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: Enabling compatibility mode for protocol 2.0 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: permanently_set_uid: 107/65534 [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: list_hostkey_types: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: SSH2_MSG_KEXINIT sent [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: SSH2_MSG_KEXINIT received [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: kex: algorithm: curve25519-sha256 [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: rekey after 134217728 blocks [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: SSH2_MSG_NEWKEYS sent [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: expecting SSH2_MSG_NEWKEYS [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: SSH2_MSG_NEWKEYS received [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: rekey after 134217728 blocks [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: KEX done [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: userauth-request for user LED service ssh-connection method none [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: attempt 0 failures 0 [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: PAM: initializing for "LED" Jul 29 16:01:47 raspberrypi sshd[707]: debug1: PAM: setting PAM_RHOST to "192.168.101.253" Jul 29 16:01:47 raspberrypi sshd[707]: debug1: PAM: setting PAM_TTY to "ssh" Jul 29 16:01:47 raspberrypi sshd[707]: debug1: userauth-request for user LED service ssh-connection method publickey [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: attempt 1 failures 0 [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for RSA SHA256:V8iqoIwrpARwkx2WpM0BBvxnJC/52+pRQU6Hkyxq62s [preauth] Jul 29 16:01:47 raspberrypi sshd[707]: debug1: temporarily_use_uid: 10001/100 (e=0/0) Jul 29 16:01:47 raspberrypi sshd[707]: debug1: trying public key file /home/LED/.ssh/authorized_keys Jul 29 16:01:47 raspberrypi sshd[707]: debug1: Could not open authorized keys '/home/LED/.ssh/authorized_keys': Permission denied Jul 29 16:01:47 raspberrypi sshd[707]: debug1: restore_uid: 0/0 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: temporarily_use_uid: 10001/100 (e=0/0) Jul 29 16:01:47 raspberrypi sshd[707]: debug1: trying public key file /home/LED/.ssh/authorized_keys2 Jul 29 16:01:47 raspberrypi sshd[707]: debug1: Could not open authorized keys '/home/LED/.ssh/authorized_keys2': Permission denied Jul 29 16:01:47 raspberrypi sshd[707]: debug1: restore_uid: 0/0 Jul 29 16:01:47 raspberrypi sshd[707]: Failed publickey for LED from 192.168.101.253 port 39312 ssh2: RSA SHA256:V8iqoIwrpARwkx2WpM0BBvxnJC/52+pRQU6Hkyxq62s

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Y.H.

2019/07/29 10:02

ディレクトリとファイルのオーナーは問題ないですか?
vektor

2019/07/29 10:14

オーナーについても問題ないと思います。(少なくともオーナー、グループについても確認し修正しました。)
guest

回答1

0

自己解決

PiServerの機能でユーザを作らず、rootターミナルを用いて直接ユーザを作成し、その時にホームディレクトリを既定の/home/users/ではなくroot直下に作成したディレクトリ(/xxxxx/)にして後は通常通りに公開鍵認証の設定をするとうまく公開鍵でパスワード不要でssh接続が出来ました。
ありがとうございます。

投稿2019/08/01 08:48

vektor

総合スコア6

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問