mirror of
https://github.com/chubin/cheat.sheets
synced 2024-11-12 19:10:26 +00:00
61 lines
2.4 KiB
Plaintext
61 lines
2.4 KiB
Plaintext
# ssh
|
|
# access a remote host via SSH
|
|
|
|
# SSH in via PEM file, which normally needs 0600 permissions.
|
|
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.
|
|
ssh -p 2222 user@example.com
|
|
|
|
# Connect and forward the authentication agent.
|
|
ssh -A user@example.com
|
|
|
|
# Execute a command on a remote server.
|
|
ssh -t user@example.com 'the-remote-command'
|
|
|
|
# Tunnel an X session over SSH, via X11 Forwarding.
|
|
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).
|
|
ssh -f -L 8080:remote.example.com:5000 user@personal.server.com -N
|
|
|
|
# Launch a specific X application over SSH.
|
|
ssh -X -t user@example.com 'chromium-browser'
|
|
|
|
# Create a SOCKS proxy on localhost and port 9999.
|
|
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
|
|
|
|
# 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 -
|
|
|
|
# Explicitly specify a key for connection. Useful if you have too many
|
|
# authentication failures for a given username.
|
|
ssh -i some_id_rsa -o IdentitiesOnly=yes them@there:/path/
|
|
|
|
# Temporarily disable `pubkey` authentication for this instance.
|
|
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
|
|
sshfs name@server:/path/to/folder /path/to/mount/point
|
|
|
|
# EMACS can read files through SSH.
|
|
# Doc: http://www.gnu.org/software/emacs/manual/html_node/emacs/Remote-Files.html
|
|
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>~?
|