Launcher Products Bitnami Documentationimaxe CLI Blog Contact
imaxe ssh access v1.0.0

SSH access, under control

Manage your server's remote access without editing files by hand: authorized keys, host keys, active sessions and sshd hardening, all with a configuration check before reloading.

$ imaxe ssh status
Version
v1.0.0
Subcommands
10
Config
/etc/imaxe/ssh.yml
Requires root
yes
Managed user
ubuntu

What this module does #

SSH is the way into your server: the encrypted channel you connect through to administer it. Making sure that door is properly fitted —with the right keys and no extra locks— is what separates a secure server from an exposed one.

The ssh module brings the tasks of that remote access together in a single command: it manages the user's authorized keys (add, list, remove), controls the host keys the server identifies itself with to clients, shows the active sessions, and checks or reapplies the sshd hardening defined in your configuration. Every operation that touches sshd validates the configuration first (sshd -t) so a mistaken change can't lock you out.

Before you start

Keep a session open while you change keys or restart sshd: that way, if something goes wrong, you're still in to fix it. By default the module works on the managed user ubuntu; use --user to operate on another.

Quick startstep-by-step tasks

Common tasks #

Pick what you want to do. Each recipe comes with the command already written — just swap in your own user or key, and hit Copy.

1

View SSH access status

Check at a glance that sshd is active and properly configured.

Connect to your server over SSH as the ubuntu user and run:

terminal
$ sudo imaxe ssh status

Need it for a script? Add --json and you'll get the same information, machine-readable:

terminal
$ sudo imaxe ssh status --json
You'll see whether sshd is active, which port it listens on, and a summary of the applied hardening.
2

Add or remove an authorized key

Grant access to a new machine or revoke one you no longer use.

First, look at which keys are currently authorized for the managed user:

terminal
$ sudo imaxe ssh keys list

Add a public key by passing it as an argument (or use - to read it from standard input):

terminal
$ sudo imaxe ssh keys add "ssh-ed25519 AAAAC3Nz... ana@portatil" --comment "ana@portatil"

No longer need it? Remove it by its fingerprint or its comment:

terminal
$ sudo imaxe ssh keys remove "ana@portatil"
The user's authorized_keys is updated. Check the result with keys list.
3

Regenerate host keys after cloning

Essential after creating a machine from an AMI.

When you clone an image, every copy inherits the same server identity. Generate fresh, unique host keys for this machine:

terminal
$ sudo imaxe ssh hostkeys regenerate --yes
The server gets its own identity. Note: the fingerprint changes, so each client's first reconnection will ask you to accept it again.
4

Review and reapply the hardening

Check that sshd is still configured as it should be, and fix it if not.

Compare the current hardening with the desired one (the one your configuration defines):

terminal
$ sudo imaxe ssh harden show

Any differences? Reapply the hardening from the YAML and reload sshd safely:

terminal
$ sudo imaxe ssh harden reapply
The configuration returns to the desired state (no root over SSH, no passwords, public key only) and sshd reloads without dropping your session.
5

View sessions and restart sshd

See who's connected and apply changes without fear of locking yourself out.

List the SSH sessions active right now:

terminal
$ sudo imaxe ssh sessions

To apply configuration changes, prefer reload (it doesn't drop connections); use restart only if a full restart is needed. Both validate the configuration first:

terminal
$ sudo imaxe ssh reload
$ sudo imaxe ssh restart
If the configuration is invalid, the operation stops before applying it — your access stays intact.
Careful not to lock yourself out

Before restarting sshd or changing the port, keep a second emergency session open. If, on reconnecting, you get a different host key warning after a hostkeys regenerate, that's expected: accept the new identity.

CLI referencecommands, flags and files

Synopsis #

usage
imaxe ssh <subcomando> [<subcomando-anidado>] [argumentos] [flags]

Operations that read or modify sshd, the authorized keys or the host keys require root privileges (use sudo). The keys, hostkeys and harden groups gather their own nested subcommands. Add --json to status, sessions, keys list or harden show for output suitable for scripting.

Subcommands #

SubcommandWhat it doesRelevant flags
statussshd status: active, port and hardening summary.--json
keys listLists the managed user's authorized keys.--user, --json
keys addAdds a public key (from argument or stdin).--user, --comment
keys removeRemoves a key by fingerprint or comment.--user
hostkeys regenerateRegenerates the host keys (critical after cloning an AMI; changes the fingerprint).--yes
sessionsLists the active SSH sessions.--json
harden showShows the current hardening against the desired one.--json
harden reapplyReapplies the hardening from the YAML and reloads sshd.
restartRestarts sshd, validating the configuration first (sshd -t).
reloadReloads sshd, validating the configuration first (sshd -t).

Arguments and flags #

Argument / FlagTypeDefaultDescription
<clave> req.stringIn keys add: the public key, or - to read it from stdin.
<selector> req.stringIn keys remove: fingerprint (SHA256:...) or comment of the key to remove.
--userstringubuntuUser whose authorized_keys is queried or modified (in keys list/add/remove).
--commentstringIn keys add: comment associated with the key to identify it later.
--yesboolfalseIn hostkeys regenerate: confirms without prompting (changes the fingerprint clients see).
--jsonboolfalseIn status, sessions, keys list and harden show: emits the result as JSON on stdout.

Files and paths #

PathContents
/etc/imaxe/ssh.ymlModule configuration: port, login policies (root, password, public key), allowed users, managed user and host key regeneration.
/home/<usuario>/.ssh/authorized_keysThe managed user's authorized public keys that keys add/remove modify.
/etc/ssh/sshd_config.d/Fragments of sshd configuration where the hardening is applied.
/etc/ssh/ssh_host_*_keyHost keys that identify the server and that hostkeys regenerate renews.

Example ssh.yml:

/etc/imaxe/ssh.yml
port: 22
permit_root_login: "no"
password_authentication: "no"
pubkey_authentication: "yes"
allow_users: []
managed_user: ubuntu
hostkeys:
  regenerate_on_first_boot: true

Exit codes and logs #

Each run returns a code you can check with echo $? — handy for chaining in scripts:

0OKOperation completed successfully.
1ERRGeneric unclassified error. Check the log.
2USAGEInvalid or missing arguments.
3CONFIGThe sshd -t validation failed; nothing was applied.
4NOTFOUNDKey or user not found.
5RELOADChange applied but the sshd reload failed.

Follow the service log live while debugging:

terminal
$ sudo journalctl -u ssh -f
$ sudo imaxe ssh harden show --json

Troubleshooting #

SymptomLikely causeFix
Returns CONFIG (code 3)The hardening or a manual change left sshd with an invalid configuration.Review the diff with imaxe ssh harden show and fix it; validation prevents applying a broken config.
On reconnecting, a different host key warningThe host keys were regenerated (expected after cloning an AMI).This is normal: accept the new identity on the client and update your known_hosts.
keys add returns NOTFOUND (code 4)The user given in --user doesn't exist on the system.Check the username or use the default managed one (ubuntu).
I can no longer log in with a passwordpassword_authentication is set to "no" by the hardening.This is intentional: log in with a public key and manage them with imaxe ssh keys.

Stuck with the SSH module?

Write to us with the output of «imaxe <module> status --json» and we'll get back to you fast.

Contact support