使用ansible期望创建nessus用户(nessuscli) [英] using ansible expect to create nessus user (nessuscli)

查看:167
本文介绍了使用ansible期望创建nessus用户(nessuscli)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ansible期望为我的nessus创建一个用户(通过使用nessuscli).期望应该回答以下几个问题(我添加了数字1-5).我的期望卡在数字5上.数字5的最后一个字母是(用户可以设置空规则集)",然后是下一行(回车).由于我不知道如何告诉您期望有一个短语后接下一行,因此出现了问题.我尝试了\ r \ n,但没有一个起作用!任何治疗都值得赞赏.

I'm using ansible expect to create a user for my nessus (by using the nessuscli). the expect should answer few question as below (I added the numbers 1-5). My expect get stuck at number 5. the last letters of number 5 is the "(the user can have an empty rules set)" and then the next line (carriage return). This makes the issue as I dont know how to tell expect that there is a phrase that is followed by a next line. I tried \r \n and none of them worked! any healp is appreciated.

此外,您还可以在下面看到我的ansible代码.

Also, you can see my ansible code below.

谢谢

您可以在此处查看nessus cli propmt的屏幕截图:内塞利提示的屏幕截图

you can see the screenshot of the nessus cli propmt here: screenshot of nessucli propmpt

============ Nessuscli adduser提示=========

============ Nessuscli adduser Prompt(s) ==========

1-登录名:

2-登录密码:

3-再次输入登录密码:

3- Login password (again):

4-您是否希望该用户成为Nessus的系统管理员"用户(可以上传插件等)?(y/n)[n]:y

4- Do you want this user to be a Nessus 'system administrator' user (can upload plugins, etc.)? (y/n) [n]: y

5-用户规则

nessusd具有规则系统,可用于限制主机该测试有权进行测试.例如,您可能想要他只能扫描自己的主机.

nessusd has a rules system which allows you to restrict the hosts that test has the right to test. For instance, you may want him to be able to scan his own host only.

请参阅Nessus命令行参考以获取规则语法

Please see the Nessus Command Line Reference for the rules syntax

输入该用户的规则,并在完成后输入空白行:(用户可以设置一个空规则)

Enter the rules for this user, and enter a BLANK LINE once you are done : (the user can have an empty rules set)

====================================================

===================================================

我的Ansible代码:

My Ansible Code:

名称:创建nessus用户

name: create nessus user

expect:
  command: /opt/nessus/sbin/nessuscli adduser
  responses:
    'Login: ': "{{nessus_username}}" # answer number 1
    'Login password: ': "{{nessus_pass}}" # answer number 2
    'Login password \(again\): ': "{{nessus_pass}}" # answer number 3
    '\[n\]: ': 'y' # answer number 4
    'set\)\\n ': "\n" # answer number 5 which doesnt work
    '\[n\]: ': 'y' # answer the next propmpt (not in question and works)

推荐答案

经过一番修补,这对我有用:

After much tinkering, this did it for me:

  - name: Add user
    expect:
      echo: yes
      timeout: 5
      command: "{{ nessus_cli_bin }} adduser"
      responses:
        (.*)Login(.*): "{{ nessus_user }}"
        (.*)Login password(.*): "{{ nessus_pass }}"
        (.*)Login password(.*): "{{ nessus_pass }}"
        (.*)system administrator(.*): "y"
        (.*)rules set(.*): "\n"
        (.*)ok(.*): "y"

这篇关于使用ansible期望创建nessus用户(nessuscli)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆