authorized_keys
Quick Reference
Command Name:
authorized_keys
Category:
networking
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
SSH key management
Manage authorized SSH keys for secure authentication
- 2
Security
Ensure secure communication between systems
- 3
Scripting
Use in shell scripts to automate SSH key management
- 4
Remote administration
Administer remote systems securely
Syntax
Located at: ~/.ssh/authorized_keys
Options
Option | Description |
---|---|
command="command" | Forces a specific command to be executed when this key is used for authentication |
from="pattern-list" | Restricts logins with this key to come from specified host names or IP addresses |
no-port-forwarding | Prevents TCP port forwarding when authenticated with this key |
no-agent-forwarding | Disables authentication agent forwarding for this key |
no-X11-forwarding | Prevents X11 forwarding when authenticated with this key |
no-pty | Prevents allocation of a pseudo-terminal when authenticating with this key |
no-user-rc | Prevents execution of ~/.ssh/rc by ssh when authenticating with this key |
permitopen="host:port" | Restricts port forwarding to specified destination only |
environment="NAME=value" | Sets environment variables when this key is used for login |
Examples
How to Use These Examples
The examples below show common ways to use the authorized_keys
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQ... user@hostname" >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-host
cat ~/.ssh/authorized_keys
ls -la ~/.ssh/