0.環境

[CentOS] 5.6

1.問題

  • 文中、画像内の【】は読み替えて下さい。

  • 下記ページ内の「リモートサーバでの実行」にそってRundeckのリモート接続を試してみました。

    “ジョブスケジューラ「Rundeck」を試してみる”

    ところが、このエラーが発生…

    RundeckSSHエラー

    • 上記画像内のテキストはこちら。

      22:34:10 remote 1. hogeと表示。 Authentication failure connecting to node: "remote". Make sure your resource definitions and credentials are up to date.
      22:34:10 Failed: AuthenticationFailure: Authentication failure connecting to node: "remote". Make sure your resource definitions and credentials are up to date.
      22:34:10 localhost Execution failed: 21: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [remote: AuthenticationFailure: Authentication failure connecting to node: "remote". Make sure your resource definitions and credentials are up to date.]}, Node failures: {remote=[AuthenticationFailure: Authentication failure connecting to node: "remote". Make sure your resource definitions and credentials are up to date.]}, status: failed]
      

2.デバッグ

  • まずはRundeckで対象プロジェクトの[Prepare and Run…]-[Log level] を”Debug”に変更し、エラーの詳細を表示させます。

    • 詳細を見ると、最初の公開鍵認証で失敗し、さらにその後のパスワード認証でも失敗しているようです。

      22:37:48 Authentications that can continue: publickey,password,keyboard-interactive
      22:37:48 Next authentication method: publickey
      22:37:48 Authentications that can continue: password,keyboard-interactive
      22:37:48 Next authentication method: password
      22:37:48 Disconnecting from 【IPアドレス】 port 22
      22:37:48 Authentication failure connecting to node: "remote". Make sure your resource definitions and credentials are up to date.
      22:37:48 Failed: AuthenticationFailure: Authentication failure connecting to node: "remote". Make sure your resource definitions and credentials are up to date.
      

    おかしいなあ、公開鍵認証で接続できる設定なんだけど…

    • Rundeck以前にそもそもsshで失敗しているようなので、ssh単体で実行してみます。

      ssh -i $(awk '/framework.ssh.keypath = / {print $3}' /etc/rundeck/framework.properties) rundeck@【IPアドレス】
      
    • さらにコマンドを簡素化して実行してみると、パスワード未設定の公開鍵を使っているのになぜかパスワードを聞かれます。

      [22:16:34][rundeck@【サーバー名】 ~/.ssh]$ ssh -i /var/lib/rundeck/.ssh/id_rsa rundeck@【IPアドレス】
      rundeck@【IPアドレス】's password: 
      Permission denied, please try again.
      rundeck@【IPアドレス】's password: 
      Permission denied, please try again.
      rundeck@【IPアドレス】's password: 
      Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
      

3.原因と解決

  • 色々試した結果、接続先サーバーにある公開鍵ファイルのパーミッションが原因でした。

    • <接続元>

      ssh -i /var/lib/rundeck/.ssh/id_rsa rundeck@【IPアドレス】
      
    • <接続先>

      • パーミッションが緩い分には問題ないだろうと思っていたら、厳密に600じゃないとダメなんですね…

      • chmod 600 authorized_keys を実行し、下記のように修正したらssh接続もRundeckからのリモート接続も成功しました。

        • (変更前)

          -rw-rw-r--. 1 rundeck rundeck 403 2月 4 15:58 2016 authorized_keys
          
        • (変更後)

          -rw-------. 1 rundeck rundeck 403 2月 4 15:58 2016 authorized_keys
          

参考になった記事