SSH keys and SSH configuration
This page covers two related command groups:
ssh-key- manage SSH authorised keys for users.ssh- manage the SSH server (sshd) configuration.
SSH key management
The ssh-key group manages entries in a user's authorized_keys file. Keys added by Abstrax carry a managed marker comment so they can be identified and managed later.
abstrax ssh-key <action> <user> [arguments] [flags]
A managed key looks like this in the file:
# abstrax:key id=github-deploy name="GitHub deploy key"
ssh-ed25519 AAAAC3... user@example
Permissions
The ssh-key commands do not enforce a root check in code. In practice, editing another user's ~/.ssh/authorized_keys requires sufficient file permissions, which usually means running as root or as the target user. Use sudo when managing keys for a user other than yourself.
The username argument is validated using the same rules as the user commands.
ssh-key add
Add a public key for a user.
abstrax ssh-key add <user> "<key>" [flags]
abstrax ssh-key add <user> <path-to-key> --from-file [flags]
| Flag | Description |
|---|---|
--name |
Key name / ID stored in the managed marker |
--comment |
Comment stored in the managed marker |
--expires |
UTC time in RFC3339, for example 2026-11-07T23:59:00Z. Written as OpenSSH expiry-time. sshd refuses the key after that time. Requires OpenSSH 8.2 or later |
--from |
Comma-separated IP addresses or CIDRs allowed to use this key. Written as OpenSSH from |
--from-file |
Treat the key argument as a file path and read the key from it |
--force |
Overwrite if the key already exists |
Examples
sudo abstrax ssh-key add deploy "ssh-ed25519 AAAAC3... ci@example"
sudo abstrax ssh-key add deploy "ssh-ed25519 AAAAC3..." --name=github-deploy --comment="CI key"
sudo abstrax ssh-key add deploy /home/deploy/id_ed25519.pub --from-file
sudo abstrax ssh-key add deploy "ssh-ed25519 AAAAC3..." --name=github-deploy --expires=2026-11-07T23:59:00Z --from=140.82.112.0/20,143.55.64.0/20
--expires and --from are optional. Without them, the key line is written exactly as it is today. With them, Abstrax puts the OpenSSH options in front of the key:
# abstrax:key id=github-deploy name="github-deploy"
expiry-time="202611072359Z",from="140.82.112.0/20,143.55.64.0/20" ssh-ed25519 AAAAC3...
ssh-key list and ssh-key info read those options back as expires_at (RFC3339, or null), from (the address list, or null), and expired (true once expires_at is in the past). Keys written by older Abstrax versions, which have no options, still list and remove as before. A past --expires value is rejected, and each --from item must be an IP address or CIDR with no quotes.
Example output
SSH key added for deploy.
ID: github-deploy
Name: github-deploy
Fingerprint: SHA256:abc123...
ssh-key remove
Remove a managed key by its ID. By default only managed keys can be removed.
abstrax ssh-key remove <user> <key-id> [flags]
| Flag | Description |
|---|---|
--fingerprint |
Match the key by fingerprint instead of relying only on the ID |
--force |
Remove even keys that are not managed by Abstrax |
sudo abstrax ssh-key remove deploy github-deploy
sudo abstrax ssh-key remove deploy github-deploy --fingerprint=SHA256:abc123...
ssh-key list
List the keys for a user. Does not require root if you can read the file.
abstrax ssh-key list <user>
abstrax ssh-key list <user> --managed-only
| Flag | Description |
|---|---|
--managed-only |
Show only keys managed by Abstrax |
Example output
ID TYPE FINGERPRINT MANAGED
github-deploy ssh-ed25519 SHA256:abc123... yes
ssh-key info
Show details for a single key.
abstrax ssh-key info <user> <key-id>
ID: github-deploy
Name: GitHub deploy key
Type: ssh-ed25519
Fingerprint: SHA256:abc123...
Comment: CI key
Managed: yes
SSH server configuration
The ssh group manages the SSH server configuration. Abstrax writes its settings to a drop-in that sshd reads before files such as 50-cloud-init.conf:
/etc/ssh/sshd_config.d/00-abstrax.conf
The next write moves an existing /etc/ssh/sshd_config.d/99-abstrax.conf into that file, so settings that cloud-init was overriding start to apply. If sshd_config does not include the drop-in directory, or sets the same keyword before Include, Abstrax updates that keyword in sshd_config as well.
Before reloading, the configuration is validated with sshd -t when sshd is available. After reload, Abstrax checks sshd -T. If the new value did not take effect, the command fails and names the file that still wins. --dry-run writes nothing. See Security.
abstrax ssh <action> [arguments] [flags]
abstrax ssh config <action> [arguments] [flags]
Permissions
ssh config show does not require root. All other ssh commands change configuration or restart the service and require root.
ssh config show
Show the settings sshd -T is using, including defaults. Does not require root. Each value is followed by its source: abstrax for the managed drop-in, default when sshd is using its built-in value, or the path of another file.
abstrax ssh config show
Port: 22 (default)
PermitRootLogin: prohibit-password (default)
PasswordAuthentication: no (abstrax)
ClientAliveInterval: 0 (default)
JSON keeps the same keys and adds a source for each value: port_source, permit_root_login_source, password_authentication_source, and client_alive_interval_source.
If sshd -T is unavailable, the command says so and reads the config files instead.
ssh config set-port
Change the SSH listening port. Without --allow-firewall, Abstrax warns that the firewall was left unchanged.
sudo abstrax ssh config set-port 2222
sudo abstrax ssh config set-port 2222 --allow-firewall
sudo abstrax ssh config set-port 2222 --allow-firewall --close-old-port
| Flag | Description |
|---|---|
--allow-firewall |
Open the new port in the firewall before sshd is reloaded |
--close-old-port |
Close the previous SSH port after the new one is accepting connections |
The port value is validated as a number in the range 1-65535.
With --allow-firewall, the new port is opened before sshd reloads. The previous port stays open until you pass --close-old-port, so you can test a new connection first. If the new port does not answer, the change is rolled back.
When SELinux is enforcing, Abstrax labels the new port. When sshd is socket-activated, Abstrax writes /etc/systemd/system/ssh.socket.d/abstrax-port.conf so the socket listens on the new port and the previous one until you close the old port.
ssh config set-timeout
Set the SSH client alive interval (idle timeout) in seconds.
sudo abstrax ssh config set-timeout 300
Root login and password authentication
sudo abstrax ssh config disable-root-login
sudo abstrax ssh config enable-root-login
sudo abstrax ssh config enable-root-login --keys-only
sudo abstrax ssh config disable-password-auth
sudo abstrax ssh config enable-password-auth
enable-root-login writes PermitRootLogin yes, which also allows a password when password authentication is on. --keys-only writes prohibit-password, so root can log in with an SSH key and not a password. On OpenSSH builds that still print without-password from sshd -T, Abstrax treats that value as equal to prohibit-password, and ssh config show normalizes it to prohibit-password. disable-root-login writes no and blocks root for every method.
disable-password-auth prints a warning reminding you to confirm you have a working SSH key before disabling password logins.
ssh reload and ssh restart
sudo abstrax ssh reload
sudo abstrax ssh restart
reloadreloads the SSH server.restartrestarts it, and warns that active sessions will briefly disconnect.
Notes and warnings
- Changing the SSH port or disabling password authentication can lock you out of the server. Make sure you have working alternative access (a key, or another open session) before applying these changes.
- Use
--dry-runto preview the changes first.