From 2042cb9aefaa278fd93d73005fb1e929a9aea5d9 Mon Sep 17 00:00:00 2001 From: Randy8080 Date: Tue, 13 Jul 2021 16:21:56 +0800 Subject: [PATCH] Added some code --- ssh.md | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/ssh.md b/ssh.md index 4e43ffb..e1561cc 100644 --- a/ssh.md +++ b/ssh.md @@ -26,10 +26,11 @@ Connect on a specific port ```shell script $ ssh root@192.168.1.5 -p 6222 ``` -Connect via pem file (0600 permissions) +Connect via pem file (0400 permissions) ```shell script $ ssh -i /path/file.pem root@192.168.1.5 ``` +See: [SSH Permissions](/chmod#ssh-permissions) ### Executing Executes remote command @@ -47,7 +48,7 @@ $ ssh root@192.168.1.5 "tar cvzf - ~/source" > output.tgz -### scp {.row-span-2} +### SCP {.row-span-2} Copies from remote to local ```shell script @@ -76,23 +77,26 @@ $ scp user@server:/dir/* . ### Config location -System-wide ssh config -```shell script -/etc/ssh/ssh_config -``` -User-specific ssh config -```shell script -~/.ssh/config -``` +| File Path | Description | +|--------------------------|----------------------| +| `/etc/ssh/ssh_config` | System-wide config | +| `~/.ssh/config` | User-specific config | +| `~/.ssh/id_{type}` | Private key | +| `~/.ssh/id_{type}.pub` | Public key | +| `~/.ssh/known_hosts` | Logged in host | +| `~/.ssh/authorized_keys` | Authorized login key | ### SCP Options -| Options | Description | -|---------------|----------------------| -| scp `-C` | Compresses data | -| scp `-v` | Prints verbose info | -| scp `-P` 8080 | Uses a specific Port | +| Options | Description | +|---------------|------------------------------------------------| +| scp `-r` | Recursively copy entire directories | +| scp `-C` | Compresses data | +| scp `-v` | Prints verbose info | +| scp `-P` 8080 | Uses a specific Port | +| scp `-B` | Batch mode _(Prevents password)_ | +| scp `-p` | Preserves times and modes | ### Config sample @@ -148,17 +152,17 @@ $ ssh-copy-id -i ~/.ssh/id_rsa.pub user@server SSH keygen {.cols-5} --------------- -### Explain {.col-span-2} +### ssh-keygen {.col-span-2} ```shell script $ ssh-keygen -t rsa -b 4096 -C "your@mail.com" ``` ---- -|- | - | - | -|---|---------------|---------------------------| -| | `-t` | [Type](#key-type) of key | -| | `-b` | The number of bits in the key | -| | `-C` | Provides a new comment | +| - | - | - | +|---|------|-------------------------------| +| | `-t` | [Type](#key-type) of key | +| | `-b` | The number of bits in the key | +| | `-C` | Provides a new comment | {.left-text} Generate an RSA 4096 bit key with email as a comment