Package: salt-bootstrap-ssh
Salt minion SSH bootstrapNoteThis is unlikely to work on systems other than Ubuntu 20.04.  Bones are in place
to expand to other versions and OS types.  Please feel free to offer patches.Example usageRunning from a minion host, this willInstall and activate ssh server, if not already installedGrant password-less sudo to current user, if not already explicitly named in /etc/sudoersAdd Salt masteryour_masterpublic SSH key to current user's authorized_keys,
if not already existing.  Key will be read via ssh fromyour_masteras current user (you will be prompted to provide a password)salt-bootstrap-ssh--allyour_masterYou can avoid the password prompt by setting an environment variableSALT_BOOTSTRAP_SSH_MASTER_PASSWD=some_passwordsalt-bootstrap-ssh--allyour_masterTo create a new local Salt ssh minion service accounta_salt_user will be added to local systema_salt_user will have a randomly generated long complex passworda_salt_user will be added to /etc/sudoers file with NOPASSWD optionsalt-bootstrap-ssh--all--useryour_useryour_masterYou can change which account is used to ssh the Master's ssh public keysalt-bootstrap-ssh--master-ssh-useryour_master_useryour_masterGeneral usagesalt-bootstrap-ssh [-h] [--all] [--install-ssh] [--enable-ssh]
[--user USER] [--create-user] [--grant-sudo]
[--master-ssh-user MASTER_SSH_USER]
[--master-pki-dir MASTER_PKI_DIR]
[--master-ssh-port MASTER_SSH_PORT]
salt_masterBootstrap key based SSH authentication to a Salt MasterThis streamlines the effort to enable a Salt master to use salt-ssh on a minion.
This script should be run on a minion you would like to control via a named
Salt master.You will be prompted for a Salt master SSH password unless the
SALT_BOOTSTRAP_SSH_MASTER_PASSWD environment variable is set.Supports recent (systemd based) versions of Ubuntu and Redhat.positional arguments:
salt_master           The hostname or IP address of the Salt master to
bootstrap againstoptional arguments:-h, --help:            show this help message and exit--all:                 Shortcut to enable all script options. This infers
--install-ssh, --enable-ssh, --create-user, and
--grant-sudo--install-ssh:         Install a local ssh server if needed. The will
leverage the local package management system.--enable-ssh:          Enable local ssh server if needed. The will leverage
the local service manager.--user USER:           Named user to bootstrap (default: current user).--create-user:         Create named user if needed. User created will have a
randomly generated large complex password assigned
with /home/{user} home directory and /bin/bash shell--grant-sudo:          Named user will be added to /etc/sudoers with NOPASSWD
privilege (e.g. the user can leverage sudo without
providing a password--master-ssh-userMASTER_SSH_USER:
The user to authenticate to Salt master with. This
user should either have access to the Salt master PKI
directory, or have sudo capabilities to cat the Salt
master public RSA key (default: current user).--master-ssh-user-no-sudo:
Do not use sudo if the --master-ssh-user is not
root.By default, it is assumed that --master-ssh-user
can sudo without a password on the Salt master.--master-pki-dirMASTER_PKI_DIR:
The base Salt PKI directory on the Salt master. The
master RSA public key will be referenced from here
(default: /etc/salt/pki/master).--master-ssh-portMASTER_SSH_PORT:
The base Salt PKI directory on the Salt master. The
master RSA public key will be referenced from here
(default: 22).##HISTORY1.0.0initial release1.1.0change method to read master public key from sftp to ssh with cat commandadd --master-ssh-port option1.1.1fix issue with HOME/.ssh creation1.1.2fix issue installing openssh client/server on Ubuntu 20