SaltStack Salt through SSH - SaltStack

How to execute salt through SSH?

Salt executes commands in a remote system by utilizing salt-minion. This is the typical conduct. In a few situations, the remote system can be gotten to just by the SSH protocol. For these situations, Salt gives a choice to interface the remote system utilizing the SSH protocol just and execute the command through the SSH layer.

Salt SSH is anything but difficult to arrange. The main required configuration is to indicate the remote system subtleties in a unique file called as the Roster File. This list file is regularly situated in/and so forth/salt/program. The program File will have all the data with respect to the remote system and how might we associate with it. When the list Files are arranged, all the Salt commands are executed utilizing the salt-ssh rather than the salt command.

Roster File

The Roster System is structured explicitly for Salt SSH. This is planned as a pluggable system. The sole motivation behind the program system is to accumulate data about the remote system. The list File is a YAML based configuration file containing remote system data as targets. These objectives are an extraordinary information structure with a predefined set of qualities. A list File contains at least one targets and each objective is distinguished by a Salt ID.

The fundamental structure of the program File is as per the following –

The various traits bolstered by the program File is discretionary. They are as per the following −

  • port − SSH port number.
  • sudo − whether to run the command via sudo.
  • sudo_user − sudo user name.
  • tty − true if sudo is enabled.
  • priv − private key.
  • timeout − timeout for an SSH connection.
  • minion_opts − dictionary of minion opts.
  • thin_dir − target system's storage directory for salt components.
  • cmd_umask − umask to force for the salt-call command.

The example program File is as per the following –

Deploy SSH Keys

Salt SSH will create a default open/private key sets for SSH logins. The default path will be/and so on/salt/pki/ace/ssh/salt-ssh.rsa. This key can be sent to the remote system utilizing the ssh-duplicate id command as demonstrated as follows.

Execute Command

Executing a salt command is as straightforward as changing the salt cli command into salt-ssh as demonstrated as follows.

Raw Shell Command

Salt SSH gives an alternative (- r) to execute a crude command in the remote system bypassing the salt module and functions.

Targeting with Salt SSH

Targeting on the remote system in Salt SSH bolsters just glob and regex targets. Since Salt SSH is a different module, it gives just restricted alternatives starting at now and will give more Features sooner rather than later.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

SaltStack Topics