TCP Wrapper 特殊使用

來源:互聯網
上載者:User

標籤:

  更多,更好內容請參見: http://www.ibm.com/developerworks/cn/aix/library/au-tcpwrapper/

一. 用處和用法

  沒有符合hosts.allow,hosts.deny中的配置的主機,用ssh登陸到我的系統的時候,我希望記錄下他的動作,以便用於查詢認證只用,這個時候就可以用到TCP Wrappers 的特殊功能。 但是要確定安裝tcp_wrappers軟體才能使用: " yum install tcp_wrappers"。 這時,就會有更加詳細的操作:

  spawn : 可以利用後續的shell進行額外的工作,並且可以使用變數:

    %h:  hostname

    %a:  address

    %d:  daemon

  twist:  立刻一後續的命令進行,且執行完後終止此次串連

二. 簡單範例

  1. spawn的使用:

    1.1 設定hosts.allow,hosts.deny. 加入相應的spawn配置。

    達到的目標: 如果是未經允許的網段登入到我的主機時,就向root賬戶發送一條mail,mail的內容形式為:

      security notice from host ****

      the host **** which is not permitted tried to ssh to you computer

    hosts.allow

## hosts.allow    This file contains access rules which are used to#        allow or deny connections to network services that#        either use the tcp_wrappers library or that have been#        started through a tcp_wrappers-enabled xinetd.##        See ‘man 5 hosts_options‘ and ‘man 5 hosts_access‘#        for information on rule syntax.#        See ‘man tcpd‘ for information on tcp_wrappers#sshd:    192.168.1.2,192.168.1.1: allow

    hosts.deny

    

## hosts.deny    This file contains access rules which are used to#        deny connections to network services that either use#        the tcp_wrappers library or that have been#        started through a tcp_wrappers-enabled xinetd.##        The rules in this file can also be set up in#        /etc/hosts.allow with a ‘deny‘ option instead.##        See ‘man 5 hosts_options‘ and ‘man 5 hosts_access‘#        for information on rule syntax.#        See ‘man tcpd‘ for information on tcp_wrappers#sshd:    ALL    :spawn ( echo "security notice from host $(/bin/hostname)"; \
          echo "the host %h which is not permitted tried to ssh to you computer"; echo;) |      /bin/mail -s "%d-%h security" root

    1.2 用不在允許範圍的主機192.168.1.12嘗試用ssh登陸到這台主機(192.168.1.11)

    主機拒絕登陸

    

    1.3 在主機(192.168.1.11)查看收到的新mai,內容如下:

    l

  2.twist用法

    在hosts.deny檔案後邊加上設定:

    

## hosts.deny    This file contains access rules which are used to#        deny connections to network services that either use#        the tcp_wrappers library or that have been#        started through a tcp_wrappers-enabled xinetd.##        The rules in this file can also be set up in#        /etc/hosts.allow with a ‘deny‘ option instead.##        See ‘man 5 hosts_options‘ and ‘man 5 hosts_access‘#        for information on rule syntax.#        See ‘man tcpd‘ for information on tcp_wrappers#sshd:    ALL    :spawn ( echo "security notice from host $(/bin/hostname)"; \
          echo "the host %h which is not permitted tried to ssh to you computer"; echo;) |      /bin/mail -s "%d-%h security" root &      :twist (/bin/echo "YOU ARE NOT ALLOWED TO ENTER THE COMPUTER")

    在192.168.1.12上用ssh登陸到192.168.1.11上時,並沒有出現YOU ARE NOT ALLOWED TO ENTER THE COMPUTER。 尋找了很長時間的問題,但是依然沒有解決。

    這樣 sshd: ALL :twist (/bin/echo "YOU ARE NOT ALLOWED TO ENTER THE COMPUTER"),也不行。

    求高手解答

    

TCP Wrapper 特殊使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.