Restricted SSH Keys for Automated Jobs¶
A job that runs without a person present cannot enter a two-factor authentication (2FA) code. Configure a dedicated, command-restricted SSH key and request a 2FA exemption from support so unattended scripts can connect to Ngarrgu Tindebeek (NT), OzSTAR, or the data-movers without modifying your normal interactive login key.
For interactive sessions and manual transfers, use Reusing SSH connections (multiplexing) instead.
What we can and cannot approve¶
We cannot exempt an unrestricted SSH key from 2FA. An exempt key cannot open an interactive shell, runs only its approved command, and — for rrsync — is confined strictly to its approved directory.
HPC staff may review restricted entries in ~/.ssh/authorized_keys at any time without notice. If an entry no longer matches the approved restriction, the exemption may be removed.
Before you start¶
Complete Two-Factor Authentication (2FA) enrollment and confirm that your normal interactive SSH login works.
Know the project directory you need to access and the source IP address (or CIDR range) from which the automated job connects.
Send and receive data through a data-mover rather than a login node. The examples below connect to
data-mover03.hpc.swin.edu.au; see Transferring Files for the full list of data-movers.In every example below, replace
<username>with your OzSTAR username,<project>with your project directory,<source>with the IP address or CIDR range the job connects from (for example,203.0.113.0/24), and<dir>/<dir1>–<dir4>with your actual directory names.
Step 1: Create a dedicated key¶
On the machine that runs the automated job, generate a dedicated SSH key for this job only:
ssh-keygen -t ed25519 -f ~/.ssh/automation -N '' -C unattended-job
cat ~/.ssh/automation.pub
The key has no passphrase so the unattended job can use it without prompting. Choose a filename that is not already in use, and send support only the .pub file — never share the private key.
Step 3: Request the exemption¶
Email hpc-support@swin.edu.au with:
Your OzSTAR username
The IP address (or CIDR range) the job connects from
The command or destination directory, including the full restricted
authorized_keysentryThe public key from the
.pubfile
An approved exemption applies only to that specific restricted key, never to all logins on your account.
Step 4: Test the key¶
Run all tests from the machine and network that will execute the automated job.
Before the exemption is approved¶
The key works before the exemption is approved, but 2FA still prompts. Verify that the key is installed by connecting to the host the job uses (for an rsync job, a data-mover):
ssh -i ~/.ssh/automation -o IdentitiesOnly=yes -o ControlPath=none <username>@data-mover03.hpc.swin.edu.au
Enter your 2FA code when prompted. Reaching the 2FA prompt confirms that your restricted key was accepted. After entering the code, an rrsync entry exits with Not invoked via sshd and a fixed-command entry prints its output. Either result confirms the key is configured correctly and is only waiting on the 2FA exemption.
After the exemption is confirmed¶
Once support confirms the exemption, the same connection runs without prompting for a 2FA code. Test the full command with --dry-run first:
# Test pulling data (lists files without copying)
rsync -av --dry-run -e 'ssh -i ~/.ssh/automation -o IdentitiesOnly=yes -o ControlPath=none' <username>@data-mover03.hpc.swin.edu.au:/fred/<project>/data/<dir>/ dest/
# Test pushing data (lists files without copying)
rsync -av --dry-run -e 'ssh -i ~/.ssh/automation -o IdentitiesOnly=yes -o ControlPath=none' local/ <username>@data-mover03.hpc.swin.edu.au:/fred/<project>/incoming/
For a fixed command or fixed script running on a login node:
ssh -i ~/.ssh/automation -o IdentitiesOnly=yes -o ControlPath=none <username>@ozstar.swin.edu.au
The first two commands list matching files without copying; the last prints the fixed command output and never opens an interactive shell.
Warning
Do not add BatchMode=yes to your automated ssh options. BatchMode=yes disables the keyboard-interactive authentication method used by the 2FA subsystem, causing even an exempted key to be refused.
If any test still prompts for a 2FA code, the exemption is not yet active on that host.
What the restriction does not do¶
from= restricts the source address, command= fixes what executes, and restrict disables interactive terminals and port forwarding. These controls limit what a party holding the automation key can do — they do not restrict you, because you control ~/.ssh/authorized_keys. A write-only key (-wo -no-del) can still overwrite existing files inside its allowed destination directory.
Next steps¶
Transferring Files — recommended
rsyncflags and data-mover addresses.Connecting via SSH — set up interactive connection reuse with multiplexing.
User Support — contact
hpc-support@swin.edu.auwith exemption requests or troubleshooting questions.