salt擴展認證PAM篇

salt.states.external_auth

概述

salt 擴展認證 PAM,能夠利用PAM 認證機制對系統帳戶作出功能操做上的限制html

  1. 認證用戶不容許使用root
  2. 能夠限制認證用戶可以使用的功能模塊
  3. 能夠限定認證用戶可管理的主機

官方文檔:http://docs.saltstack.com/topics/eauth/index.htmlubuntu

開啓PAM認證

編輯 /etc/salt/masterthis

<pre> external_auth: pam: salt: - '*' </pre>code

建立 salt 用戶 設置密碼htm

驗證

salt PAM 認證用戶 只能經過 「 -a pam 」 參數才能使用文檔

<pre> salt -a pam test.ping </pre>get

會提示登錄用戶,輸入密碼,若是正確返回結果,說明pam認證已經生效it

實例 :

/etc/salt/masterio

external_auth:
  pam:
    admin:
      - '*'                        # 全部模塊                  
    salt:
      - test.ping                  # test.ping 模塊 
    test:
      - 'dev*':                   # 主機配置規則 
        - test.ping                # Salt 模塊

解釋:ast

  • admin 用戶可管理全部主機,使用全部salt功能模塊
  • salt 用戶可管理全部主機,僅能使用test.ping模塊
  • test 用戶只能管理部分主機,僅能使用test.ping模塊

實例1: 以salt用戶爲例,認證用戶必須打開PAM 參數才能操做

  • 失敗操做:

<pre> salt@fabrizio-vaio:~$ salt '*' test.ping Failed to authenticate, is this user permitted to execute commands? </pre>

  • 成功操做:

<pre> salt@fabrizio-vaio:~$ salt -a pam '*' test.ping username: salt password: ubuntu-master: True </pre>

實例2: 以salt用戶爲例,執行未受權模塊被拒絕

<pre> salt@fabrizio-vaio:~$ salt -a pam '*' state.highstate username: salt password: Failed to authenticate, is this user permitted to execute commands? </pre>

實例3: 以test用戶爲例,操做未受權主機被拒絕 失敗操做

<pre> salt@fabrizio-vaio:~$ salt -a pam '*' test username: test password: Failed to authenticate, is this user permitted to execute commands? </pre>

成功操做

<pre> salt@fabrizio-vaio:~$ salt -a pam 'test-001' test username: test password: test-001: True </pre>

相關文章
相關標籤/搜索