4 saltstack ssh

 1、salt ssh

https://docs.saltstack.com/en/latest/topics/ssh/index.html

agent

Salt ssh 串行

执行的时候,发送给其他的,etc目录下,跑完后删除

1.安装

[root@linux-node1 ~]# yum install salt-ssh -y

 安装后生成roster,roster花名册

记录目标的

 4 saltstack ssh

2、配置

[root@linux-node1 salt]# vim /etc/salt/roster

linux-node1:
  host: 192.168.194.131
  user: root
  passwd: redhat
  port: 22

linux-node2:
  host: 192.168.194.132
  user: root
  passwd: redhat
  port: 22
View Code

 4 saltstack ssh

3.配置ssh,需要key不验证

[root@linux-node1 ~]# salt-ssh '*' test.ping 

4 saltstack ssh

执行命令,不支持交互

交互的两种方式

1, 修改配置

2 ,添加参数

 方法1:

[root@linux-node1 ~]# salt-ssh '*' -r 'uptime'

[root@linux-node1 ~]# salt-ssh '*' -r 'ifconfig'

方法2ssh添加配置

[root@linux-node1 ~]# vim .ssh/config

StrictHostKeyChecking no

 4 saltstack ssh

执行命令

[root@linux-node1 ~]# salt '*' cmd.run 'w'

[root@linux-node1 ~]# salt-ssh '*' -r 'w'

方法3:-i, --ignore-host-keys

[root@localhost salt]# salt-ssh * test.ping -i

4、执行命令

[root@localhost salt]# salt-ssh * test.ping
192.168.209.129:
    True
192.168.209.130:
    True
[root@localhost salt]# salt-ssh * test.ping
192.168.209.130:
    True
192.168.209.129:
    True