Skip to content

Automate SSH identity and hardening for SYSTEM account#136

Open
innovara wants to merge 2 commits into
kmwoley:mainfrom
innovara:ssh-init-hardening
Open

Automate SSH identity and hardening for SYSTEM account#136
innovara wants to merge 2 commits into
kmwoley:mainfrom
innovara:ssh-init-hardening

Conversation

@innovara

Copy link
Copy Markdown
Contributor

Summary: Adds a workflow to manage SSH identities for the NT AUTHORITY\SYSTEM account to simplify the set-up of SFTP-based backups.

Changes:

  • InitializeSSH.ps1: generates Ed25519 keys and applies ACLs restricted to SYSTEM and Administrators. Uses a temporary scheduled task to handle file creation within the SYSTEM profile.
  • Installer integration: updates install.ps1 to detect SFTP repositories, run ssh-keyscan for host fingerprints, and display the public key for user authorization.
  • Permissions: implements logic to enforce directory permissions on the .ssh folder after known_hosts updates.

This script ensures that the NT AUTHORITY\SYSTEM account has a valid
Ed25519 key pair located in the systemprofile directory. It is designed
to be run either standalone or as part of an orchestration script.

Key features:
- Administrative requirement: must be run from an elevated session to
  manage the scheduled tasks and system directories.
- Use of temporary scheduled tasks to execute logic as SYSTEM, ensuring
  correct file ownership and permission application.
- Strict ACL application: removes all inherited permissions, granting
  full control only to SYSTEM and Administrators.
- Standalone capability: can be run directly to output the public key.
- Resilience: automatically reconstructs the public key from the private
  key if it is missing.

Signed-off-by: Manuel Fombuena <mfombuena@innovara.tech>
Updates the installation script to automatically configure the SSH
environment when an SFTP repository is detected.

Key features:
- Automated configuration: leverages InitializeSSH.ps1 to prepare the
  SYSTEM account's identity and permissions.
- Host trust: uses ssh-keyscan to automatically populate known_hosts
  for the target repository, ensuring non-interactive backups can proceed.
- Permission persistence: triggers re-hardening of the .ssh directory
  after modifying known_hosts.
- Interactive setup: pauses installation to display the SYSTEM public
  key, allowing the user to authorize it on the remote server.

Signed-off-by: Manuel Fombuena <mfombuena@innovara.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant