ログインパスワードのないユーザーのためのSSH

ログインパスワードのないユーザーのためのSSH

パスワードなしでユーザーを作成しました

$getent passwd logcoll
logcoll:x:998:999:Log Collector,,,:/var/backups/logcoll:/bin/sh

ユーザーにはパスワードがなく、デバイスはユーザーにSSHキーを使用してログインする必要があります。

私のIDをにコピーしました/var/backups/logcoll/.ssh/authorized_keys。ただし、このコンピュータにログインしようとすると、次のエラーが発生します。

ssh -i .ssh/id_rsa logcoll@server  
Permission denied (publickey)

ただし、このユーザーのパスワードを作成したら、次のようにpasswd logcollログインできます。

ssh -i .ssh/id_rsa logcoll@data3

したがって、質問は次のようになります。ユーザーにpamベースのパスワードを設定せずにキーベース認証を有効にするにはどうすればよいですか?

修正する

user@localhost:~$ ssh -v -i .ssh/id_rsa logcoll@server
OpenSSH_6.0p1 Debian-4+deb7u2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to user [1x.x.x.21] port 22.
debug1: Connection established.
debug1: identity file .ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file .ssh/id_rsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u2
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 15:13:8b:62:49:ad:5a:01:e6:5f:13:bd:10:c3:c1:28
debug1: Host 'data3' is known and matches the ECDSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:16
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: Offering RSA public key: .ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
user@localhost:~$ 

ファイル権限:

root@server:/var/backups/logcoll#ls -ld .ssh   
drwx------ 2 logcoll logcoll 4096 Dec  1 15:36 .ssh
root@data3:/var/backups/logcoll#ls -ld .ssh/authorized_keys
-rw------- 1 logcoll logcoll 391 Dec  1 15:29 .ssh/authorized_keys

ベストアンサー1

いいですね。私のログでいくつかの情報を見つけました。

$ sudo tail -f /var/log/auth.log  
Dec  1 16:17:14 server sshd[31251]: User logcoll not allowed because account is locked 

!シャドウアイテムを削除し、次のものと交換しました。

logcoll:NOPASSAUTHALLOWED:16384:0:99999:7:::  

man shadow状態:

たとえば、パスワードフィールドにcrypt(3)の有効な結果ではない一部の文字列が含まれているとします。または*を使用すると、ユーザーはunixパスワードを使用してログインできません(ただし、ユーザーは他の方法でシステムにログインできます)。

これがまさに私が望む行動です。

おすすめ記事