2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-17 09:25:32 +00:00
cheat.sheets/sheets/ssh

63 lines
2.4 KiB
Plaintext
Raw Normal View History

2019-01-09 16:51:57 +00:00
# ssh
# OpenSSH SSH client (remote login program)
2019-01-09 16:51:57 +00:00
# SSH in via PEM file, which normally needs 0600 permissions.
2019-01-09 16:51:57 +00:00
ssh -i /path/to/file.pem user@example.com
# Connect through a non-standard port. It's recommended not to use the default
# port of 22, as it is so often targeted, due to it being so commonplace.
2019-01-09 16:51:57 +00:00
ssh -p 2222 user@example.com
# Connect and forward the authentication agent.
2019-01-09 16:51:57 +00:00
ssh -A user@example.com
# Execute a command on a remote server.
2019-01-09 16:51:57 +00:00
ssh -t user@example.com 'the-remote-command'
# Tunnel an X session over SSH, via X11 Forwarding.
2019-01-09 16:51:57 +00:00
ssh -X user@example.com
# Redirect traffic with a tunnel between local host (port 8080) and a remote
# host (remote.example.com:5000) through a proxy (personal.server.com).
2019-01-09 16:51:57 +00:00
ssh -f -L 8080:remote.example.com:5000 user@personal.server.com -N
# Launch a specific X application over SSH.
2019-01-09 16:51:57 +00:00
ssh -X -t user@example.com 'chromium-browser'
# Create a SOCKS proxy on localhost and port 9999.
2019-01-09 16:51:57 +00:00
ssh -D 9999 user@example.com
# Connect to server, but allow for X11 forwarding, while also using GZip
# compression (can be much faster; YMMV), and using the `blowfish` encryption.
# For more information, see: http://unix.stackexchange.com/q/12755/44856
ssh -XCc blowfish user@example.com
2019-01-09 16:51:57 +00:00
# Copy files and directories, via SSH, from remote host to the current working
# directory, with GZip compression. An option for when `rsync` isn't available.
#
# This works by creating (not temporary!) a remote Tar archive, then piping its
# output to a local Tar process, which then extracts it to STDOUT.
ssh user@example.com 'tar -C /var/www/Shared/ zcf - asset1 asset2' | tar zxf -
2019-01-09 16:51:57 +00:00
# Explicitly specify a key for connection. Useful if you have too many
# authentication failures for a given username.
2019-01-09 16:51:57 +00:00
ssh -i some_id_rsa -o IdentitiesOnly=yes them@there:/path/
# Temporarily disable `pubkey` authentication for this instance.
2019-01-09 16:51:57 +00:00
ssh -o PubkeyAuthentication=no username@hostname.com
# Mount a remote directory or filesystem, through SSH, to a local mountpoint.
# Install SSHFS from: https://github.com/libfuse/sshfs
2019-01-09 16:51:57 +00:00
sshfs name@server:/path/to/folder /path/to/mount/point
# EMACS can read files through SSH. Below, is a link to related documentation.
#
# http://www.gnu.org/software/emacs/manual/html_node/emacs/Remote-Files.html
#
2019-01-09 16:51:57 +00:00
emacs /ssh:name@server:/path/to/file
# Get help for SSH escape sequences. Useful for terminating unresponsive
# sessions. The default escape character is ~ (tilde), escapes are only
# recognized immediately after a newline.
$ <Enter>~?