4321ddd 发表于 2016-11-25 09:12:06

salt-ssh的使用(不需要安装客户端)

什么情况下才使用salt-ssh,有一些比较老的红帽服务器,也有一些不方便安装salt-minion客户端。总会有一些服务器比较难安装上salt-minion的。
好了,下面来说说简单配置

默认使用roster配置文件
vim /etc/salt/roster

1
2
3
4
5
6
7
8
9
10
11
12
13
# 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
hdd:                              //ID名字可以随便定义
host: 10.0.0.221
user: hdd
passwd: 66666
sudo: Ture




已经完成配置!下面直接使用salt-ssh
第一次运行没有添加-i,未能如期运行。


1
2
3
4
5
6
7
8
9
10
11
12
root@salt-master ~]# salt-ssh "*" -r 'free -m'
hdd:
    ----------
    retcode:
      254
    stderr:
    stdout:
      The host key needs to be accepted, to auto accept run salt-ssh with the -i flag:
      The authenticity of host '10.0.0.221 (10.0.0.221)' can't be established.
      ECDSA key fingerprint is b9:36:f5:d8:3a:88:94:93:43:78:8e:cb:43:78:8e:cb.
      Are you sure you want to continue connecting (yes/no)?
#




添加-i参数继续执行命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# salt-ssh "*" -r 'free -m' -i
hdd:
    ----------
    retcode:
      0
    stderr:
      Warning: Permanently added '10.0.0.221' (ECDSA) to the list of known hosts.
    stdout:
      hdd@10.0.0.221's password:
                     total       used       free   shared    buffers   cached
      Mem:          7856       6698       1157         18      317       4298
      -/+ buffers/cache:       2082       5773
      Swap:         8061          0       8061
#
# salt-ssh "hdd" -r 'df -h'            
hdd:
    ----------
    retcode:
      0
    stderr:
    stdout:
      Filesystem      SizeUsed Avail Use% Mounted on
      udev            3.9G4.0K3.9G   1% /dev
      tmpfs         786M1.5M785M   1% /run
      /dev/sda1       910G454G410G53% /
      none            4.0K   04.0K   0% /sys/fs/cgroup
      none            5.0M   05.0M   0% /run/lock
      none            3.9G   84K3.9G   1% /run/shm
      none            100M   12K100M   1% /run/user




但是我有一个问题,保存的密钥放在哪里呢?暂时我未有发现。

nika86 发表于 2017-3-24 15:31:01

11111111111111111111111

nika86 发表于 2017-3-24 15:31:07

111111111111

nika86 发表于 2017-3-24 15:31:13

111111111111111111

nika86 发表于 2017-3-24 15:31:21

2222222222222222222222222
页: [1]
查看完整版本: salt-ssh的使用(不需要安装客户端)