salt icon indicating copy to clipboard operation
salt copied to clipboard

Salt - SSH using machine IP to execute commands, without having to write a roster file

Open double-yaya opened this issue 11 years ago • 12 comments

In 2014.1.4 version I can specify the target machine execute commands, the target machine not written in the roster file command like this:

salt-ssh 'ip' test.ping --passwd rootpassword
ip:
    True 

But in 2015.5.3 version failed

result:

No hosts found with target ip of type glob 

So.....In 2015.5.3 version,the target machine must be written in a roster file?

double-yaya avatar Aug 27 '15 01:08 double-yaya

@double-yaya I was able to confirm that this is working on salt version 2014.1.4 and not working on salt version 2015.5.3. Thanks for your report.

arroyoc avatar Aug 27 '15 16:08 arroyoc

Hi, i have the same issue, and found the answer.

salt-ssh --roster=scan 'IP' test.ping --user=SSH_USER --passwd=SSH_PASSWD

yangxiangyu avatar Dec 22 '15 06:12 yangxiangyu

What is your version @yangxiangyu

double-yaya avatar Dec 22 '15 07:12 double-yaya

salt-ssh 2015.5.2 (Lithium)

yangxiangyu avatar Dec 22 '15 07:12 yangxiangyu

I am surprised this ever worked. The scan roster was always the intended solution here. The scan roster can also be used against a subnet if you want to go crazy. With the answer posted I am going to close this issue out

thatch45 avatar Jul 21 '16 21:07 thatch45

I run this command in salt-ssh 2015.8.8, return True:

sudo salt-ssh --user='root' --passwd='vagrant' --roster=scan '10.57.3.102' test.ping

the result is this:

10.57.3.102:
    True

However, I run this by python api,return error:

from salt.client.ssh.client import SSHClient
client = SSHClient(c_path='/etc/salt/master')
print client.cmd(tgt='10.57.3.102', fun='test.ping', salt_user='root', salt_passwd='vagrant', roster='scan')

the error is this:

{'10.57.3.102': {'retcode': 255, 'stderr': 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n', 'stdout': ''}}

@thatch45 @double-yaya

zjyExcelsior avatar Aug 22 '16 07:08 zjyExcelsior

The default vagrant user is vagrant

thatch45 avatar Aug 22 '16 15:08 thatch45

Why cmdline is OK, the python api is wrong?What's the difference between them?the root's password is 'vagrant', user+password matching is not enough?

zjyExcelsior avatar Aug 22 '16 16:08 zjyExcelsior

Still wrong when I use vagrant/vagrant

zjyExcelsior avatar Aug 22 '16 16:08 zjyExcelsior

Oh, I follow you now, sorry I read it too quickly the first time. This should work, I am not sure off the top of my head what is missing, but this should be a new issue, can you please open a new issue to track this please?

thatch45 avatar Aug 22 '16 16:08 thatch45

Ok

zjyExcelsior avatar Aug 22 '16 16:08 zjyExcelsior

#35664 @thatch45

zjyExcelsior avatar Aug 22 '16 16:08 zjyExcelsior