Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
# Generate an Ed25519 key pair (recommended, modern) ssh-keygen -t ed25519 -C "alice@example.com" # Prompts: # Enter file in which to save the key: ~/.ssh/id_ed25519 (Enter for default) # Enter passphrase: (use a strong passphrase) # Generate RSA key (4096-bit, for compatibility) ssh-keygen -t rsa -b 4096 -C "alice@example.com" # View the generated public key cat ~/.ssh/id_ed25519.pub # ssh-ed25519 AAAA... alice@example.com # Copy public key to remote server ssh-copy-id alice@192.168.1.50 ssh-copy-id -i ~/.ssh/id_ed25519.pub alice@192.168.1.50 # Manual method (if ssh-copy-id is unavailable) cat ~/.ssh/id_ed25519.pub | ssh alice@192.168.1.50 \ "mkdir -p ~/.ssh && chmod 700 ~/.ssh && \ cat >> ~/.ssh/authorized_keys && \ chmod 600 ~/.ssh/authorized_keys" # Connect using key authentication ssh alice@192.168.1.50 # Specify a particular key ssh -i ~/.ssh/id_ed25519 alice@server.example.com # Set correct permissions (critical!) chmod 700 ~/.ssh chmod 600 ~/.ssh/id_ed25519 chmod 644 ~/.ssh/id_ed25519.pub chmod 600 ~/.ssh/authorized_keys # List loaded keys in SSH agent ssh-add -l # Add key to SSH agent (avoids re-entering passphrase) eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
Result
Open