prerequisite concepts: prelude
If you're not already using a config file (~/.ssh/config) you should peruse the documentation to see what it offers;
As an added bonus, your accounts have usernames which differ from each other (let's use "fred" and "barney") as well as from your workstation. To log in to these machines using the command line, you would type:
ssh fred@example.com
ssh -p 23 barney@example.com
This isn't a great deal of typing but already one can see that differentiating more complex connections may be confusing when distinguished only by the port used. We can clarify things a bit with a config file like this:
Host imap
HostName example.com
User fred
Host smtp
HostName example.com
Port 23
User barney
Now our SSH commands look nicer:
ssh imap
ssh smtp
The config file can always be overridden with command line options, so ssh admin@smtp will log in as admin rather than barney, but will still use port 23 and any other options set in ~/.ssh/config. Once you start using LocalForward and ProxyCommand command line options quickly become tedious and unwieldy, even if you can remember all options for every host you attend.
One final note, in addition to acting as a convenient alias, the host keywords may also be used to make declarations for groups of servers, or all servers, by using wildcards and pattern-lists. The ssh_config man page (or your preferred documentation) has a detailed PATTERNS section, but a below is a brief example to whet your appetite:
# global declarations Host * ForwardAgent yes ForwardX11 yes # just for example.com servers Host *.example.com ServerAliveInterval 60 StrictHostKeyChecking no
[...] OpenSSH: Basic Configuration OpenSSH: Port Forwarding (working draft) OpenSSH: Proxy Connections (working draft) OpenSSH: The SSH2 Toolbox (planned) OpenSSH: Reverse Connections (planned) OpenSSH: Connection Multiplexing (planned) [...]
ReplyDelete[...] Open SSH: Port Forwarding October 16, 2008 Posted by Garrison in Uncategorized. trackback prerequisite concepts: prelude, basic configuration [...]
ReplyDelete[...] Garrison in Command Line, HowTo, Linux. Tags: OpenSSH trackback prerequisite concepts: prelude, basic configuration, Port [...]
ReplyDelete[...] OpenSSH: Basic Configuration OpenSSH: Port Forwarding OpenSSH: Proxy Connections OpenSSH: Environmental Override SSH Coolness … Even On Windows [...]
ReplyDelete