?
user模塊可管理遠(yuǎn)程主機(jī)上的 用戶,比如創(chuàng)建用戶、修改用戶、刪除用戶、為用戶創(chuàng)建密鑰對等操作。
成都創(chuàng)新互聯(lián)是創(chuàng)新、創(chuàng)意、研發(fā)型一體的綜合型網(wǎng)站建設(shè)公司,自成立以來公司不斷探索創(chuàng)新,始終堅持為客戶提供滿意周到的服務(wù),在本地打下了良好的口碑,在過去的10年時間我們累計服務(wù)了上千家以及全國政企客戶,如成都小攪拌車等企業(yè)單位,完善的項目管理流程,嚴(yán)格把控項目進(jìn)度與質(zhì)量監(jiān)控加上過硬的技術(shù)實力獲得客戶的一致稱贊。
?
append='yes'
,則從groups參數(shù)中增加用戶的屬組;如果 append='no'
,則用戶屬組只設(shè)置為groups中的組,移除其他所有屬組。state=absent
時使用,等價于 userdel --remove
布爾類型,默認(rèn)值為 false。state=absent
時使用,等價于 userdel --force
,布爾類型,默認(rèn)值為 false。/etc/shadow
文件中的的 第8列/etc/shadow
中密碼字符串不一致時更新用戶的密碼;/etc/shadow
中密碼字符串不一致時也不會更新用戶的密碼,但如果是新創(chuàng)建的用戶,則此參數(shù)即使為on_create,也會更新用戶密碼。~/.ssh
目錄中生成名為 id_rsa私鑰和 id_rsa.pub公鑰,如果同名密鑰已經(jīng)存在,則不做任何操作。generate_ssh_key=yes
時,指定生成的ssh key加密位數(shù)。generate_ssh_key=yes
時,使用此參數(shù)指定ssh私鑰的路徑及名稱,會在同路徑下生成以私鑰名開頭以 .pub
結(jié)尾對應(yīng)公鑰。generate_ssh_key=yes
時,在創(chuàng)建證書時,使用此參數(shù)設(shè)置公鑰中的注釋信息。如果同名密鑰已經(jīng)存在,則不做任何操作。當(dāng)不指定此參數(shù)時,默認(rèn)注釋信息為"ansible-generated on \$hostname”。generate_ssh_key=yes
時,在創(chuàng)建證書時,使用此參數(shù)設(shè)置私鑰密碼。如果同名密鑰已經(jīng)存在,則不做任何操作。generate_ssh_key=yes
時,在創(chuàng)建證書時,使用此參數(shù)指定密鑰對的類型。默認(rèn)值為 rsa,如果同名密鑰已經(jīng)存在,則不做任何操作。?
下列英文文檔部分來自于 ansible-doc
,參數(shù)的修飾符號為 "="或 "-"
OPTIONS (= is mandatory):=號開始的為必須給出的參數(shù)
name: 用于指定操作的 user,必須項
= name
Name of the user to create, remove or modify.
(Aliases: user)
type: str
?
使用 ansible在 note1節(jié)點上增加 test用戶
[root@note0 ~]# ansible note1 -m user -a "name=test"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1000,
"home": "/home/test",
"name": "test",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1000
}
[root@note0 ~]#
?
驗證 用戶是否 添加成功,查看 note1節(jié)點下的 /etc/passwd
文件
[root@note1 ~]# tail -1 /etc/passwd
test:x:1000:1000::/home/test:/bin/bash
?
uid: 用于指定 user的 UID,默認(rèn)為空
- uid
Optionally sets the `UID' of the user.
[Default: (null)]
type: int
使用 ansible在 note1節(jié)點上增加 testuid用戶
[root@note0 ~]# ansible note1 -m user -a "name=testuid uid=2000"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 2000,
"home": "/home/testuid",
"name": "testuid",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 2000
}
[root@note0 ~]#
?
驗證 用戶是否 添加成功,查看 note1節(jié)點下的 /etc/passwd
文件
[root@note1 ~]# tail -1 /etc/passwd
testuid:x:2000:2000::/home/testuid:/bin/bash
state: 參數(shù)用于指定用戶是否存在于遠(yuǎn)程主機(jī)中。
可選值有 present、absent:
默認(rèn)值為 present,表示用戶存在,相當(dāng)于在遠(yuǎn)程主機(jī)創(chuàng)建用戶;
當(dāng)設(shè)置為 absent時表示用戶不存在,相當(dāng)于在遠(yuǎn)程主機(jī)刪除用戶。
- state
Whether the account should exist or not, taking action if the state is different from what is stated.
(Choices: absent, present)[Default: present]
type: str
使用 ansible在 note1節(jié)點上刪除 test用戶
[root@note0 ~]# ansible note1 -m user -a "name=test state=absent"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"force": false,
"name": "test",
"remove": false,
"state": "absent"
}
[root@note0 ~]#
?
驗證 用戶是否 刪除成功,查看 note1節(jié)點下是否存在 test用戶
[root@note1 ~]# id test
id: test: no such user
remove: 參數(shù)在 state=absent
時使用,等價于 userdel --remove
布爾類型,默認(rèn)值為 false。
- remove
This only affects `state=absent', it attempts to remove directories associated with the user.
The behavior is the same as `userdel --remove', check the man page for details and support.
[Default: False]
type: bool
在 示例3.3.1中我們已經(jīng)使用 ansible在 note1節(jié)點上刪除了 test用戶,現(xiàn)在讓我們查看test用戶home目錄是否存在。
[root@note1 ~]# cd /home
#查看home目錄
[root@note1 home]# ll
總用量 0
drwx------ 2 1000 1000 59 7月 9 16:41 test
drwx------ 2 testuid testuid 59 7月 9 17:01 testuid
[root@note1 home]#
我們可以看到,通過state=absent刪除的用戶home目錄還存在,下面我們來演示一下徹底刪除一個用戶。
使用 ansible在 note1節(jié)點上刪除 testuid用戶
[root@note0 ~]# ansible note1 -m user -a "name=testuid state=absent remove=yes"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"force": false,
"name": "testuid",
"remove": true,
"state": "absent"
}
[root@note0 ~]#
?
下面我們來驗證一下,用戶及home目錄是否徹底刪除
#查看testuid用戶是否存在
[root@note1 home]# id testuid
id: testuid: no such user
#查看home目錄
[root@note1 home]# ll
總用量 0
drwx------ 2 1000 1000 59 7月 9 16:41 test
[root@note1 home]#
group: 參數(shù)用于指定用戶 主組。默認(rèn)值為空,創(chuàng)建的用戶組名跟用戶名一致。
- group
Optionally sets the user's primary group (takes a group name).
[Default: (null)]
type: str
使用 ansible在 note1節(jié)點上 創(chuàng)建test用戶,并指定主組為 testgrp
#首先創(chuàng)建使用ansible創(chuàng)建testgrp組
[root@note0 ~]# ansible note1 -m group -a "name=testgrp state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"gid": 1000,
"name": "testgrp",
"state": "present",
"system": false
}
#使用ansible創(chuàng)建test用戶
[root@note0 ~]# ansible note1 -m user -a "name=test group=testgrp state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1000,
"home": "/home/test",
"name": "test",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1000
}
[root@note0 ~]#
?
驗證 用戶是否 創(chuàng)建成功
[root@note1 home]# id test
uid=1000(test) gid=1000(testgrp) 組=1000(testgrp)
groups: 參數(shù)用于指定用戶屬組,可以在創(chuàng)建用戶時指定用戶屬組,也可以管理已經(jīng)存在的用戶屬組。
groups為列表類型,多個參數(shù)以逗號分隔,例如 groups='grp,mygrp'
;默認(rèn)值為 空,也可以設(shè)置空字符串 groups='',groups=`null`,groups=`~`,將用戶從其他屬組 移除。
append: 跟groups參數(shù)一起使用管理用戶屬組。布爾類型,默認(rèn)為false,如果 append='yes'
,則從groups參數(shù)中增加用戶的屬組;如果 append='no'
,則用戶屬組只設(shè)置為groups中的組,移除其他所有屬組。
- groups
List of groups user will be added to. When set to an empty string `''', `null', or `~', the user is removed from all groups
except the primary group. (`~' means `null' in YAML)
Before Ansible 2.3, the only input format allowed was a comma separated string.
[Default: (null)]
type: list
- append
If `yes', add the user to the groups specified in `groups'.
If `no', user will only be added to the groups specified in `groups', removing them from all other groups.
[Default: False]
type: bool
先使用 ansible在 note1節(jié)點上創(chuàng)建 mygrp1,mygrp2,mygrp3測試組
#首先創(chuàng)建使用創(chuàng)建測試組
[root@note0 ~]# ansible note1 -m group -a "name=mygrp1 gid=2001 state=present"
[root@note0 ~]# ansible note1 -m group -a "name=mygrp2 gid=2002 state=present"
[root@note0 ~]# ansible note1 -m group -a "name=mygrp3 gid=2003 state=present"
#測試組創(chuàng)建成功
[root@note1 home]# cat /etc/group
mygrp1:x:2001:
mygrp2:x:2002:
mygrp3:x:2003:
?
創(chuàng)建用戶 testuser,并指定屬組為 mygrp1mygrp2
[root@note0 ~]# ansible note1 -m user -a "name=testuser groups=mygrp1,mygrp2 state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1001,
"groups": "mygrp1,mygrp2",
"home": "/home/testuser",
"name": "testuser",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1001
}
[root@note0 ~]#
?
驗證用戶 testuser的屬組為mygrp1,mygrp2
[root@note1 home]# id testuser
uid=1001(testuser) gid=1001(testuser) 組=1001(testuser),2001(mygrp1),2002(mygrp2)
將testuser的屬組變更為mygrp1,mygrp2,mygrp3
[root@note0 ~]# ansible note1 -m user -a "name=testuser groups='mygrp1,mygrp2,mygrp3' state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"append": false,
"changed": true,
"comment": "",
"group": 1001,
"groups": "mygrp1,mygrp2,mygrp3",
"home": "/home/testuser",
"move_home": false,
"name": "testuser",
"shell": "/bin/bash",
"state": "present",
"uid": 1001
}
[root@note0 ~]#
?
驗證用戶testuser的屬組是否為mygrp1,mygrp2,mygrp3
[root@note1 home]# id testuser
uid=1001(testuser) gid=1001(testuser) 組=1001(testuser),2001(mygrp1),2002(mygrp2),2003(mygrp3)
先將testuser用戶屬組還原為mygrp1,mygrp2
再增加屬組mygrp3
#使用append=yes時,只將要添加的屬組填入groups參數(shù)中即可。
[root@note0 ~]# ansible note1 -m user -a "name=testuser groups='mygrp3' append=yes state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"append": true,
"changed": true,
"comment": "",
"group": 1001,
"groups": "mygrp3",
"home": "/home/testuser",
"move_home": false,
"name": "testuser",
"shell": "/bin/bash",
"state": "present",
"uid": 1001
}
[root@note0 ~]#
?
驗證用戶testuser的屬組是否為mygrp1,mygrp2,mygrp3
[root@note1 home]# id testuser
uid=1001(testuser) gid=1001(testuser) 組=1001(testuser),2001(mygrp1),2002(mygrp2),2003(mygrp3)
將testuser的屬組變更為mygrp1
[root@note0 ~]# ansible note1 -m user -a "name=testuser groups='mygrp1' state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"append": false,
"changed": true,
"comment": "",
"group": 1001,
"groups": "mygrp1",
"home": "/home/testuser",
"move_home": false,
"name": "testuser",
"shell": "/bin/bash",
"state": "present",
"uid": 1001
}
[root@note0 ~]#
?
驗證用戶testuser的屬組是否為mygrp1
[root@note1 home]# id testuser
uid=1001(testuser) gid=1001(testuser) 組=1001(testuser),2001(mygrp1)
先將testuser用戶屬組還原為mygrp1,mygrp2,mygrp3
再變更用戶testuser屬組為mygrp3
#使用append=no時,用戶的屬組只設(shè)置為groups參數(shù)中的組
[root@note0 ~]# ansible note1 -m user -a "name=testuser groups='mygrp1' append='no' state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"append": false,
"changed": true,
"comment": "",
"group": 1001,
"groups": "mygrp1",
"home": "/home/testuser",
"move_home": false,
"name": "testuser",
"shell": "/bin/bash",
"state": "present",
"uid": 1001
}
[root@note0 ~]#
?
驗證用戶testuser的屬組是否為mygrp1
[root@note1 home]# id testuser
uid=1001(testuser) gid=1001(testuser) 組=1001(testuser),2001(mygrp1)
passwd: 參數(shù)用于指定用戶密碼,但是這個密碼不能是明文密碼,而是一個對明文密碼加密后的字符串,相當(dāng)于?/etc/shadow
?文件中的密碼字段,是一個對明文密碼進(jìn)行哈希后的字符串,可以使用命令生成明文密碼對應(yīng)的加密字符串。
- password
Optionally set the user's password to this crypted value.
On macOS systems, this value has to be cleartext. Beware of security issues.
To create a disabled account on Linux systems, set this to `'!'' or `'*''.
See https://docs.ansible.com/ansible/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module for details on various
ways to generate these password values.
[Default: (null)]
type: str
?
要生成md5算法的密碼,使用openssl即可。
openssl passwd -1 '123456'
openssl passwd -1 -salt 'abcdefg' '123456'
?
但 openssl passwd
不支持生成sha-256和sha-512算法的密碼。使用python命令生成sha-512算法
python -c 'import crypt,getpass;pw="123456";print(crypt.crypt(pw))'
?
現(xiàn)在就方便多了,直接將結(jié)果賦值給變量即可。
[root@note0 ~]# a=$(python -c 'import crypt,getpass;pw="123456";print(crypt.crypt(pw))')
[root@note0 ~]# echo $a
$6$uKhnBg5A4/jC8KaU$scXof3ZwtYWl/6ckD4GFOpsQa8eDu6RDbHdlFcRLd/2cDv5xYe8hzw5ekYCV5L2gLBBSfZ.Uc166nz6TLchlp.
?
例如,ansible創(chuàng)建用戶并指定密碼:
[root@note0 ~]# a=$(python -c 'import crypt,getpass;pw="123456";print(crypt.crypt(pw))')
[root@note0 ~]# ansible note1 -m user -a 'name=testpass password="$a" update_password=always'
[WARNING]: The input password appears not to have been hashed. The 'password' argument must be encrypted for this module to work properly.
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1005,
"home": "/home/testpass",
"name": "testpass",
"password": "NOT_LOGGING_PASSWORD",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1005
}
[root@note0 ~]#
?
登錄驗證
[root@note0 ~]# ssh testpass@note1
testpass@note1's password:
Last login: Thu Jul 11 00:12:57 2019 from note0
[testpass@note1 ~]$ who am i
testpass pts/1 2019-07-11 00:13 (note0)
[testpass@note1 ~]$
expires: 參數(shù)用于指定用戶過期時間,相當(dāng)于設(shè)置 /etc/shadow
文件中的的 第8列,比如,你想要設(shè)置用戶的過期日期為2019年07月10日,那么你首先要獲取2019年07月10日的 unix 時間戳,使用命令 date -d 20190710 +%s
獲取到的時間戳為1562688000,所以,當(dāng)設(shè)置 expires=1562688000
時,表示用戶的過期時間為2019年07月10日0點0分,設(shè)置成功后,查看遠(yuǎn)程主機(jī)的 /etc/shadow
文件,對應(yīng)用戶的第8列的值將變成18086(表示1970年1月1日到2019年07月10日的天數(shù),unix 時間戳的值會自動轉(zhuǎn)換為天數(shù),我們不用手動的進(jìn)行換算),當(dāng)前ansible版本此參數(shù)支持在GNU/Linux, FreeBSD, and DragonFlyBSD系統(tǒng)中使用。
設(shè)置一個過期時間為20190710的用戶testexprie
[root@note0 ~]# ansible note1 -m user -a "name=testexpire expires=1562688000 comment='expires date is 20190710' state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "expires date is 20190710",
"create_home": true,
"group": 1003,
"home": "/home/testexpire",
"name": "testexpire",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1003
}
[root@note0 ~]#
?
在note1上驗證testexprie用戶
[root@note1 home]# cat /etc/shadow
testexpire:!!:18086:0:99999:7::18086:
登錄失敗,提示賬號過期
[root@note0 ~]# ssh testexpire@note1
testexpire@note1's password:
Your account has expired; please contact your system administrator
Connection closed by 176.16.128.1
home: 參數(shù)用于指定用戶home目錄,值為路徑
- home
Optionally set the user's home directory.
[Default: (null)]
type: path
- create_home
Unless set to `no', a home directory will be made for the user when the account is created or if the home directory does not
exist.
Changed from `createhome' to `create_home' in Ansible 2.5.
(Aliases: createhome)[Default: True]
type: bool
- move_home
If set to `yes' when used with `home: ', attempt to move the user's old home directory to the specified directory if it isn't
there already and the old home exists.
[Default: False]
type: bool
[root@note0 ~]# ansible note1 -m user -a "name=testhome home=/home/testdir state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1004,
"home": "/home/testdir",
"name": "testhome",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1004
}
[root@note0 ~]#
?
驗證testhome用戶的home目錄
# 首先登錄note1節(jié)點,su到testhome用戶
[root@note1 ~]# su - testhome
# cd 到主目錄
[testhome@note1 ~]$ cd ~
# 執(zhí)行pwd
[testhome@note1 ~]$ pwd
/home/testdir
[testhome@note1 ~]$
_move_home:_ 如果設(shè)置為yes,結(jié)合home=使用,臨時遷移用戶家目錄到特定目錄
- move_home
If set to `yes' when used with `home: ', attempt to move the user's old home directory to the specified directory if it isn't
there already and the old home exists.
[Default: False]
type: bool
首先創(chuàng)建testmove用戶,然后在testmove用戶home目錄下創(chuàng)建test_move_home.txt文件
#創(chuàng)建testmove用戶。
[root@note0 ~]# ansible note1 -m user -a "name=testmove state=present"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1006,
"home": "/home/testmove",
"name": "testmove",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1006
}
#使用ansible的file模塊在testmove用戶home目錄下創(chuàng)建test_move_home.txt文件
[root@note0 ~]# ansible note1 -m file -a "path=/home/testmove/test_move_home.txt state=touch"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"dest": "/home/testmove/test_move_home.txt",
"gid": 0,
"group": "root",
"mode": "0644",
"owner": "root",
"size": 0,
"state": "file",
"uid": 0
}
#在note1節(jié)點上,查看/home/testmove下是否存在test_move_home.txt
[root@note1 ~]# cd /home/testmove
[root@note1 testmove]# ll
總用量 0
-rw-r--r-- 1 root root 0 7月 11 06:22 test_move_home.txt
[root@note1 testmove]#
使用ansible的move_home參數(shù)遷移用戶home目錄
#遷移testmove用戶的home目錄至/tmp/testmove_new
[root@note0 ~]# ansible note1 -m user -a "user=testmove move_home=yes home=/tmp/testmove_new/"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"append": false,
"changed": true,
"comment": "",
"group": 1006,
"home": "/tmp/testmove_new/",
"move_home": true,
"name": "testmove",
"shell": "/bin/bash",
"state": "present",
"uid": 1006
}
[root@note0 ~]#
驗證遷移的新home目錄下是否存在test_move_home.txt文件
[root@note1 testmove]# cd /tmp/testmove_new/
[root@note1 testmove_new]# ll
總用量 0
-rw-r--r-- 1 root root 0 7月 11 06:22 test_move_home.txt
[root@note1 testmove_new]#
_generate_ssh_key:_ 參數(shù)用于指定是否生成ssh密鑰對,布爾類型,默認(rèn)為false。當(dāng)設(shè)置為yes時,為用戶生成 ssh 密鑰對,默認(rèn)在 ~/.ssh
目錄中生成名為 id_rsa私鑰和 id_rsa.pub公鑰,如果同名密鑰已經(jīng)存在,則不做任何操作。
- generate_ssh_key
Whether to generate a SSH key for the user in question.
This will *not* overwrite an existing SSH key unless used with `force=yes'.
[Default: False]
type: bool
version_added: 0.9
使用ansible創(chuàng)建testssh用戶,并生成ssh_key。
[root@note0 ~]# ansible note1 -m user -a "name=testssh state=present generate_ssh_key=yes"
176.16.128.1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1007,
"home": "/home/testssh",
"name": "testssh",
"shell": "/bin/bash",
"ssh_fingerprint": "2048 07:18:48:ea:f1:dc:95:22:75:fc:b5:5e:80:25:a7:1f ansible-generated on note1 (RSA)",
"ssh_key_file": "/home/testssh/.ssh/id_rsa",
"ssh_public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIrQCOP11FK/s50vpOm/z+hXEmet+oEdWqGbyQD0JdN0AJrS/MzHZF3v+sjMf4SoDL7PafPYnFY4iVEtNOuBK8uvQgziVXVRxPs7h9Yy+ZdFw8qFjeiC74pKl+0Mqq49I9TD1GMbOQRd0K7nTycymCAX0MW5lQz7q44f3qa4+4y8C63xxi/4H9x3lJ+JsjDDIzKo4i69CnqU3Bn+0HzfxYi9j63HtcdLF8OwVfyF73lK6xd+vK68AaxRfPIOEj4KJXU3iMdiM5zVvMZgjEKyaGKPJD/uQl35MV2oazmFHTHWrKgA5AXwJEMKJYJzF6a8Z6SrmSnvxp6TpnMmbXAjev ansible-generated on note1",
"state": "present",
"system": false,
"uid": 1007
}
[root@note0 ~]#
驗證note1節(jié)點下的ssh_key文件
[root@note1 ~]# cd /home/testssh/.ssh
[root@note1 .ssh]# ll
總用量 8
-rw------- 1 testssh testssh 1679 7月 11 06:39 id_rsa
-rw-r--r-- 1 testssh testssh 408 7月 11 06:39 id_rsa.pub
[root@note1 .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIrQCOP11FK/s50vpOm/z+hXEmet+oEdWqGbyQD0JdN0AJrS/MzHZF3v+sjMf4SoDL7PafPYnFY4iVEtNOuBK8uvQgziVXVRxPs7h9Yy+ZdFw8qFjeiC74pKl+0Mqq49I9TD1GMbOQRd0K7nTycymCAX0MW5lQz7q44f3qa4+4y8C63xxi/4H9x3lJ+JsjDDIzKo4i69CnqU3Bn+0HzfxYi9j63HtcdLF8OwVfyF73lK6xd+vK68AaxRfPIOEj4KJXU3iMdiM5zVvMZgjEKyaGKPJD/uQl35MV2oazmFHTHWrKgA5AXwJEMKJYJzF6a8Z6SrmSnvxp6TpnMmbXAjev ansible-generated on note1
[root@note1 .ssh]#
?
ansible的user模塊常用參數(shù)就介紹到這里,不做過多贅述了。歡迎指點交流。