Browse all 16 guides
Pro 5 min read

Migrate Your SSH Port & Manage Authorized Keys Safely

Move sshd off port 22 with firewall pre-opening and automatic rollback, and manage authorized_keys without cutting access.

Security SSH

What you will accomplish

  • Migrate SSH to a custom port with pre-flight port probing and firewall updates.
  • Rely on automatic sshd_config backup and rollback if daemon reload fails.
  • Manage authorized_keys with double confirmation preventing in-use key deletion.
Safe SSH Port Migration Wizard · 22 → 2222
Rollback Armed
1. Port Probe Available

Verifies 2222 is free

2. Firewall Open Opened

Allows 2222 before reload

3. Config Backup Backed Up

Saves sshd_config copy

4. Syntax & Reload Verified

Auto-restores on error

Prerequisites

  • Active 14-day Pro trial or Pro subscription.
  • Root or sudo privilege capability.

How Hmpify handles this workflow

Concept Behavior Where in App
In-Use Key Guard Identifies and refuses deleting the SSH public key currently authenticating your session. Authorized Keys
In-Place Rewrite Updates authorized_keys safely one key per line without breaking permissions. Authorized Keys
Atomic Port Rollback Tests target port availability, opens firewall rules, and restores sshd_config if reload fails. Port Wizard

Audit and update authorized_keys safely

Ensure key-based authentication is in place before hardening sshd password settings.

  • Open Security → SSH and review the active user’s authorized_keys entries.
  • Paste new public keys one per line and remove obsolete keys — Hmpify refuses deleting the key currently authenticating your session.
Safety Guard

Disabling password authentication is safest after confirming a key-based login succeeds in a test session.

Run the Safe SSH Port Migration Wizard

Coordinate port binding, firewall rules, and sshd syntax validation in one guided workflow.

  • Enter your target port (e.g. 2222) and launch the migration.
  • Hmpify probes target port availability, opens the new port in UFW or firewalld, backs up sshd_config, validates syntax, and reloads sshd.
sshd -t   # Executed automatically before sshd reload
Expected result: sshd listens on the new port while automatically restoring backup config on any reload failure.

Update your Hmpify profile and retire port 22

Confirm connectivity on the new port before closing the old port.

  • Edit your server profile SSH port to 2222 and reconnect to confirm access.
  • Return to Security → Firewall to remove the legacy port 22 rule.

Troubleshooting

Migration aborts before modifying sshd_config.

Another process already owns the port, or SELinux on AlmaLinux/Rocky requires labeling the custom port.

14-Day In-App Pro Trial

Run this guarded workflow in Hmpify

Every copy includes a built-in 14-day Pro trial covering all 19 Linux administration modules — flat $5/mo or $50/yr across unlimited hosts.