パスワードを入力しないとsshログインを設定できません


8

次のようにして、サーバーへのパスワードを入力せずに自動的にsshログインを設定します。

cd ~/.ssh

ssh-keygen

ssh-copy-id -i ~/.ssh/id_rsa.pub tim@server1

サーバー上で動作します。

その後、別のサーバーで同じことを行いました。

ssh-copy-id -i ~/.ssh/id_rsa.pub tim@server2

すぐに私はssh tim@server2、それでも私のパスワードが必要です。何か間違ったことをしましたか?2台目のサーバーで正常にセットアップできなかった理由として考えられるものは何ですか?(2番目のサーバーはkerberosおよびAndrewファイルシステムを実行していることに注意してください)

$ ssh -v tim@server2
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to server2 [...] port 22.
debug1: Connection established.
debug1: identity file /home/tim/.ssh/id_rsa type 1
debug1: identity file /home/tim/.ssh/id_rsa-cert type -1
debug1: identity file /home/tim/.ssh/id_dsa type -1
debug1: identity file /home/tim/.ssh/id_dsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ecdsa type -1
debug1: identity file /home/tim/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ed25519 type -1
debug1: identity file /home/tim/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
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: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA xxx
debug1: Host 'server2' is known and matches the RSA host key.
debug1: Found key in /home/tim/.ssh/known_hosts:70
debug1: ssh_rsa_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,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/tim/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Trying private key: /home/tim/.ssh/id_dsa
debug1: Trying private key: /home/tim/.ssh/id_ecdsa
debug1: Trying private key: /home/tim/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Password:

AntiffのDiffie-Hellmanキーを使用する方法を試しましたが、それでもパスワードを要求されます。

$ cd ~/.ssh
$ ssh-keygen -t dsa
$ ssh-copy-id -i ~/.ssh/id_dsa.pub tim@server2
$ ssh -v tim@server2
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to server2 [...] port 22.
debug1: Connection established.
debug1: identity file /home/tim/.ssh/id_rsa type 1
debug1: identity file /home/tim/.ssh/id_rsa-cert type -1
debug1: identity file /home/tim/.ssh/id_dsa type 2
debug1: identity file /home/tim/.ssh/id_dsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ecdsa type -1
debug1: identity file /home/tim/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ed25519 type -1
debug1: identity file /home/tim/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
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: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA ...
debug1: Host 'server2' is known and matches the RSA host key.
debug1: Found key in /home/tim/.ssh/known_hosts:70
debug1: ssh_rsa_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,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/tim/.ssh/id_dsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Offering RSA public key: /home/tim/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Trying private key: /home/tim/.ssh/id_ecdsa
debug1: Trying private key: /home/tim/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Password:

ログイン後にホームディレクトリがマウントされていますか?
muru

過去にログインするたびに、私の家はいつもマウントされていました。
Tim

はい、ログインするとホームディレクトリが表示されますが、ログインが完了する前はどうですか。(暗号化されたホームディレクトリ、またはネットワークホームディレクトリなどを検討してください)
muru

server2Andrewファイルシステムを使用していると聞きました。ログインが完了する前に家がマウントされないということですか?どのように私はあなたの質問にそれを見つけることができますか?
Tim

Andrewファイルシステムがどのように機能するかはわかりませんが、同じサーバーに別のログインがある場合は、それを使用して、timのホームディレクトリの内容が表示されるかどうかを確認してください。
muru

回答:


10

あなたは、2番目のサーバーがAndrew File System(AFS)を使用していると述べました。

私はこれで作業していませんが、私が理解しているところによると、AFSはKerberosで保護されたファイルシステムであり、動作するにはKerberosチケットが必要です。つまり、ホームディレクトリにアクセスするには、サイトのKerberosレルムにログインする必要があります。

パスワードを使用してログオンする場合、server2は、PAMを介してKerberosレルムにログオンするように設定されている可能性があります。ただし、SSHキーを使用している場合は、そのserver2ために必要な情報を取得できず、ホームディレクトリにアクセスできません。

幸い、ssh -v質問の出力から、サーバーでGSSAPI認証が有効になっていると推測できます。これにより、レルムの有効なkerberosチケットがあれば、パスワードなしのログオンを実行できます。以下をせよ:

  • にログオンしserver2klistプログラムを実行します。これは、次の行に沿って何かを返します。

    Ticket cache: FILE:/tmp/krb5cc_2000
    Default principal: wouter@EXAMPLE.ORG
    
    Valid starting     Expires            Service principal
    28-05-15 15:01:31  29-05-15 01:01:31  krbtgt/EXAMPLE.ORG@EXAMPLE.ORG
        renew until 29-05-15 15:01:28
    28-05-15 15:02:04  29-05-15 01:01:31  IMAP/example.org@EXAMPLE.ORG
        renew until 29-05-15 15:01:28
    

    で始まる行を探しますDefault principal:。kerberosプリンシパルが何であるかを示します(上記の例ではwouter@EXAMPLE.ORG)。これを書き留めてください。これはメールアドレスではなく、大文字と小文字が区別されることに注意してください。つまり、プリンシパルはでEXAMPLE.ORGはなくで終わりexample.orgます。

  • クライアントマシンkinitで、プリンシパルの名前を使用して実行します(つまり、上記の例では、になりますkinit wouter@EXAMPLE.ORG)。すべてが順調に進んだら、klist今すぐもう一度実行すると、ローカルマシンにチケットキャッシュがあることがわかります。
  • ここでを実行するとssh -K server2、ログオンできるようになり、システムはパスワードを要求しなくなります。

Kerberosの仕組みにより、チケットキャッシュの有効性には制限があることに注意してください。レルム管理者が構成したもの(通常は10時間程度)よりも長い有効期間のチケットキャッシュを要求することはできません。チケットの有効期限が切れたら、kinitもう一度実行してパスワードをもう一度入力する必要があります。


ありがとう。「クライアントマシンでkinitを実行します」ということは、ローカルのUbuntuにKerberosをインストールする必要があるということですか?
Tim

はい、ケルベロスツールの一部です。必要なツールはkrb5-userパッケージに含まれています。
Wouter Verhelst 2015年

公開鍵を作成してサーバーにコピーするときに、rsaまたはdsaを使用する必要がありますか?(私は今すぐdsaを使用するというAnthonの提案に従いました)
Tim

サーバー上のAFSのため、SSH公開鍵は使用できません。代わりに、Kerberosを使用する必要があります。したがって、それは問題ではありません;-)
Wouter Verhelst '30

GSSAPI、DSA、RSAはすべて認証方法ですか?
Tim

5

あなたはserver2への接続を試みる必要があります:

ssh -v tim@server2

server1これを同じものと比較すると、これに接続すると、2つのサーバーの違いが正確にわかります。

ほとんどの場合、/etc/ssh/sshd_config両方のマシンで違いがあります。どこにserver2またはあなたの~/.sshアクセシビリティの問題があります(十分に制限されていません)。

-v出力から、確認するRSA秘密鍵を(で/home/tim/.ssh/id_rsa)提供していることがわかりますが、それserver2はDiffie-Hellmanのみをサポートしているように見えます(そして、 /home/tim/.ssh/id_dsaおそらくそこにもありません)。


おかげで、コマンドを実行した結果を更新しました。意味がわからない
Tim

@Timが私の回答を更新しました。RSA秘密/公開鍵をサポートしていないように見える理由をserver2管理者に確認する必要があります。
Anthon

管理者に尋ねる以外に(私の経験に基づいて変更を加えることは不可能だと思います)、サーバーが期待することを処理する方法はありますか?
Tim

@Tim、まず~/.ssh、サーバーに実際に認証済みキーがインストールされていることを確認します(~/.ssh/authorized_keys)。次に、実行できることはssh-keygen、diffie-hellman鍵ペアを生成してssh-keygen -t dsaそれをコピーすることです。
Anthon 2015年

(1)~/.ssh/authorized_keysサーバー上にファイルがあります。承認されたキーがインストールされているということですか?(2)生成されたdiffie-hellmanキーペアをサーバーにコピーするにはどうすればよいですか?によってscp ~/.ssh/id_dsa.pub tim@server2:~/.ssh/authorized_keys~/.ssh/authorized_keysサーバーで上書きしますか?
Tim

4

sshしようとしているクライアントマシンに次のエントリを追加します。

設定ファイル: /etc/ssh/ssh_config

GSSAPIAuthentication no

その後、マシンにsshできます。

そのファイルの編集権限がない場合は、追加することもできます

Host *
  GSSAPIAuthentication no

する~/.ssh/config(このファイルが存在しない場合は作成する)

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.