ssh
logout: exit or Ctrl-D (in shell it means end of input)
run remote command without going into the remote shell:
ssh user@hostname "command"
ssh keys are stored in
~/.ssh
config file: .ssh/config
With the following in the config file, ssh dev
will connect to the server.
General structure of the config file
A single ssh command can match multiple sections in the config file. If multiple sections set the same SSH_OPTION, the first one wins. Therefore the generic settings (matching *) comes last.
Common ssh options includes:
Hostname
User
SendEnv
ProxyJump
IdentityFile
ForwardAgent
Port
AddKeysToAgent
UseKeychain
ServerAliveInterval
Refs
SCP
SSH Tunnel
Example: a remote database server (orion.dev:3306
) only allows local access. On local machine we have a GUI tool, which can't connect to the remote database directly.
Solution: On local machine, use the following line to connect local port 9000 with server's port 3306 (via localhost:22, the port SSH uses). Note that the localhost
in the following line refers to the remote server.
Then the GUI tool can connect to localhost:9000
to access the remote database.
Last updated