# salt-ssh systemctl stop salt-minion标签:root,salt,192.168,host,ssh,SaltStack,pts From: https://blog.51cto.com/u_13940603/5886227
1. yum install -y salt-ssh
2. vim /etc/salt/roster
# Sample salt-ssh config file
#web1:
# host: 192.168.42.1 # The IP addr or DNS hostname
# user: fred # Remote executions will be executed as user fred
# passwd: foobarbaz # The password to use for login, if omitted, keys are used
# sudo: True # Whether to sudo to root, not enabled by default
#web2:
# host: 192.168.42.2
node1:
host: 192.168.2.104
user: root
passwd: 19920308shibin
port: 22
node2:
host: 192.168.2.103
user: root
passwd: 19920308shibin
port: 22
3. salt-ssh '*' test.ping -i
4. salt-ssh '*' -r 'w'
# 执行效果如下:
#---------------------------------------------------------------------------
node2:
----------
retcode:
0
stderr:
stdout:
[email protected]'s password:
01:09:20 up 2:20, 3 users, load average: 0.10, 0.16, 0.21
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 07:48 ? 0.38s 0.38s -bash
root pts/0 192.168.2.101 23:45 8.00s 0.74s 0.02s /usr/bin/python /usr/bin/salt-ssh * -r w
root pts/1 192.168.2.101 23:54 22:08 0.39s 0.39s -bash
node1:
----------
retcode:
0
stderr:
stdout:
[email protected]'s password:
06:56:25 up 11:47, 3 users, load average: 0.00, 0.04, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 19:09 1:24m 2.27s 2.27s -bash
root pts/0 192.168.2.101 05:32 21:37 1.39s 1.39s -bash
root pts/1 192.168.2.101 05:42 55:21 1.09s 1.09s -bash
#---------------------------------------------------------------------------