ssh_openssh_keys
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| ssh_openssh_keys [2025/02/21 00:15] – [SSH/OpenSSH/Keys] jianwu | ssh_openssh_keys [2025/02/26 03:55] (current) – jianwu | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | [[https:// | ||
| + | |||
| ===== SSH/ | ===== SSH/ | ||
| To install the OpenSSH client applications on your Ubuntu system, use this command at a terminal prompt: | To install the OpenSSH client applications on your Ubuntu system, use this command at a terminal prompt: | ||
| Line 14: | Line 16: | ||
| ==== Work As SSH Server ==== | ==== Work As SSH Server ==== | ||
| - | < | + | < |
| $ sudo ssh-keygen -A | $ sudo ssh-keygen -A | ||
| </ | </ | ||
| ^-A|Generate host keys of all default key types (rsa, ecdsa, and ed25519) if they do not already | ^-A|Generate host keys of all default key types (rsa, ecdsa, and ed25519) if they do not already | ||
| - | < | + | < |
| $ sudo / | $ sudo / | ||
| Starting ssh (via systemctl): ssh.service. | Starting ssh (via systemctl): ssh.service. | ||
| Line 26: | Line 28: | ||
| user(ex. pctr)' | user(ex. pctr)' | ||
| - | < | + | < |
| $ ssh-keygen -t rsa -b 4096 | $ ssh-keygen -t rsa -b 4096 | ||
| </ | </ | ||
| - | < | + | < |
| $ touch / | $ touch / | ||
| </ | </ | ||
| === Recommended Setting of sshd_config === | === Recommended Setting of sshd_config === | ||
| - | < | + | < |
| $ sudo vim / | $ sudo vim / | ||
| -- | -- | ||
| Line 43: | Line 45: | ||
| -- | -- | ||
| </ | </ | ||
| - | < | + | < |
| $ sudo systemctl restart ssh | $ sudo systemctl restart ssh | ||
| </ | </ | ||
| === ufw setting === | === ufw setting === | ||
| - | < | + | < |
| $ sudo ufw allow from < | $ sudo ufw allow from < | ||
| Line 57: | Line 59: | ||
| To create your public and private SSH keys on the command-line: | To create your public and private SSH keys on the command-line: | ||
| user(ex. pctr)' | user(ex. pctr)' | ||
| - | < | + | < |
| $ mkdir ~/.ssh | $ mkdir ~/.ssh | ||
| $ chmod 700 ~/.ssh | $ chmod 700 ~/.ssh | ||
| Line 63: | Line 65: | ||
| </ | </ | ||
| You will be prompted for a location to save the keys, and a passphrase for the keys. This passphrase will protect your private key while it's stored on the hard drive: | You will be prompted for a location to save the keys, and a passphrase for the keys. This passphrase will protect your private key while it's stored on the hard drive: | ||
| - | < | + | < |
| Generating public/ | Generating public/ | ||
| Enter file in which to save the key (/ | Enter file in which to save the key (/ | ||
| Line 74: | Line 76: | ||
| ==== About Key Encryption Level ==== | ==== About Key Encryption Level ==== | ||
| Note: The default is a 2048 bit key. You can increase this to 4096 bits with the -b flag (Increasing the bits makes it harder to crack the key by brute force methods). | Note: The default is a 2048 bit key. You can increase this to 4096 bits with the -b flag (Increasing the bits makes it harder to crack the key by brute force methods). | ||
| - | < | + | < |
| ex) | ex) | ||
| $ ssh-keygen -t rsa -b 4096 | $ ssh-keygen -t rsa -b 4096 | ||
| Line 92: | Line 94: | ||
| </ | </ | ||
| ==== change a ssh passphrase for private key ==== | ==== change a ssh passphrase for private key ==== | ||
| - | < | + | < |
| $ ssh-keygen -p | $ ssh-keygen -p | ||
| </ | </ | ||
| Line 122: | Line 124: | ||
| === WSL or ubuntu === | === WSL or ubuntu === | ||
| / | / | ||
| - | < | + | < |
| host ubuntu | host ubuntu | ||
| ForwardAgent yes | ForwardAgent yes | ||
| Line 132: | Line 134: | ||
| </ | </ | ||
| Usage of ssh connection | Usage of ssh connection | ||
| - | < | + | < |
| $ ssh ubuntu | $ ssh ubuntu | ||
| </ | </ | ||
| === Windows === | === Windows === | ||
| C: | C: | ||
| - | < | + | < |
| Host pctresearch | Host pctresearch | ||
| HostName host_name_of_server | HostName host_name_of_server | ||
| Line 144: | Line 146: | ||
| IdentityFile " | IdentityFile " | ||
| IdentitiesOnly yes | IdentitiesOnly yes | ||
| + | AddressFamily inet | ||
| User pctresearch | User pctresearch | ||
| Line 150: | Line 153: | ||
| ServerAliveCountMax 10000 | ServerAliveCountMax 10000 | ||
| </ | </ | ||
| + | :!: AddressFamily - Specifies which address family to use when connecting. Valid arguments are any (the default), inet (use IPv4 only), or inet6 (use IPv6 only). | ||
| + | |||
| Usage of ssh connection | Usage of ssh connection | ||
| <code Dos> | <code Dos> | ||
| - | $ ssh pctresearch | + | > ssh pctresearch |
| </ | </ | ||
ssh_openssh_keys.1740064545.txt.gz · Last modified: 2025/02/21 00:15 by jianwu