Restrict authorized key

Force-command and restrict source IP in authorized_keys

echo 'from="10.0.0.0/8",no-agent-forwarding,no-port-forwarding,command="/usr/bin/backup.sh" <pubkey>' >> ~/.ssh/authorized_keys

tool
ssh15 commands
tags
sshsecurity

More ssh commands

  • ssh -i ~/.ssh/id_ed25519 user@host

    Specify an identity file explicitly

  • ssh -J bastion.example.com user@internal-host

    Single-hop jump through bastion host

  • ssh -J user@bastion1,user@bastion2 user@target

    Chain multiple jump hosts in one command

  • ssh -L 5432:db.internal:5432 user@bastion -N

    Forward localhost:5432 to db.internal:5432 via bastion

  • ssh -R 8080:localhost:3000 user@vps -N

    Expose local port 3000 as port 8080 on VPS

all 15 ssh commands