From 7ea747b174941b71ce5296c8f702acc4fd5ad04e Mon Sep 17 00:00:00 2001 From: Ezio Date: Fri, 6 Apr 2018 23:00:52 +0800 Subject: [PATCH] =?UTF-8?q?20180406-13=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tech/20180402 Advanced SSH Cheat Sheet.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 sources/tech/20180402 Advanced SSH Cheat Sheet.md diff --git a/sources/tech/20180402 Advanced SSH Cheat Sheet.md b/sources/tech/20180402 Advanced SSH Cheat Sheet.md new file mode 100644 index 0000000000..51cb79e741 --- /dev/null +++ b/sources/tech/20180402 Advanced SSH Cheat Sheet.md @@ -0,0 +1,74 @@ +Opensource.com: Advanced SSH Cheat Sheet +=========================== + +Most people know SSH as a tool for remote login, which it is, but it can be used in many other ways. + +``` +Create a SOCKS proxy to tunnel your web traffic (like when you’re traveling) +ssh -D +Set your web browser to use localhost: as the proxy. + +Connect to a Windows RDP host behind a bastion server +ssh -L ::3389 +Set your RDP client to connect to localhost: + +Connect to your remote machine’s VNC server without opening the VNC port +ssh -L 5901:localhost:5901 +Set your VNC client to to connect to localhost:5901 +You can follow this pattern with other ports you don’t want to open to the world: LDAP (389), 631 (CUPS), 8080 (alternate HTTP), and so on. + +Generate a new SSH key pair +ssh-keygen + +Update the passphrase on an existing SSH key-pair +ssh-keygen -p + +Copy a public SSH key to a remote host +ssh-copy-id -i + +SSH has a lot of command-line options, but if you use the same options for a host regularly, you can put an entry in the SSH configuration file (${HOME}/.ssh/config) instead. For example: +host myhouse + User itsme + HostName house.example.com +Then you can type ssh myhouse instead of ssh itsme@house.example.com. +``` + +Here are common command-line options and their configuration file equivalents. Some are simplified for common use cases. See the ssh(1) and ssh_config(5) manual pages for full details. + + +|Command Line| Configuration File|Description +|:--|:--|:--| +|-l \| User \The login name on the remote machine. +|-i \ |IdentityFile \ |The identity file (SSH keypair) to use for authentication. | +|-p \| Port \|The port on which the remote SSH daemon is listening. (default: 22) | +|-C|Compression \|Compress traffic between hosts. (default: no) | +|-D \|DynamicForward \|Forward traffic on the local port to the remote machine. | +|-X|ForwardX11 \|Display X11 graphical programs from your remote host on the local host. (default: no) | +|-A|ForwardAgent \|Forward the authentication agent to the remote host. This is helpful if you’ll then connect to a third host. (default: no) | +|-4 (use IPv4 only) -6 (use IPv6 only)|AddressFamily \ |Specify whether to use IPv4 or IPv6 only. | +|-L \:\:\ |LocalForward \:\:\ |Forward local traffic on the specified to port to the remote host and port. | + +opensource.com + +Twitter @opensourceway | facebook.com/opensourceway | IRC: #opensource.com on Freenode + + + +-------------------------------------------------------------------------------- + +作者简介: + +Ben Cotton is a meteorologist by training and a high-performance computing engineer by trade. Ben works as a product marketing manger at Microsoft Azure focused on high performance computing. He is a Fedora user and contributor, co-founded a local open source meetup group, and is a member of the Open Source Initiative and a supporter of Software Freedom Conservancy. Find him on Twitter (@FunnelFiasco) or at FunnelFiasco.com. + +------------- + +via: https://opensource.com/sites/default/files/gated-content/cheat_sheet_ssh_v03.pdf + +作者:[ BEN COTTON ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/bcotton +[1]:https://web.kamihq.com/web/upgrade.html