5

I have a command, which looks like so:

$ ssh [long list of parameters, eventually I connect to internalhost]

My task is to replace this long list of parameters with just internalhost, so that I could run it like so

$ ssh internalhost

How can I do that?

  • What did you try? – SouravGhosh Dec 21 '17 at 14:44
  • I tried $ internalhost = long list of parameters, but in this case, I have to run it like $ ssh $internalhost. But it is not what I must get. – Jacobian Dec 21 '17 at 14:45
  • @steeldriver. Thank you, sir! I will check it. – Jacobian Dec 21 '17 at 14:53
7

Standard Ssh client reads the configuration files before any connection:

/etc/ssh/ssh_config   # system-wide
~/.ssh/config         # per user

with the latter with more priority.
Ideally you want to configure the systemwide config with parameters that please all users and the config in your homedir with options specific to you.
Here's an expample of ~/.ssh/config

Host remote.example.com
    User            dev1
    IdentityFIle    ~/.ssh/id_rsa_remote

Then to connect:

ssh remote.example.com

Note: ~/.ssh/config must have read/write permissions for the user, and not be accessible by others (chmod 600 ~/.ssh/config)

All possible options are documented in ssh_config manual pages: man ssh_config

5

I usually use the .ssh/config file found in my home directory to run my OpenSSH client in the format ssh ubserver. In that file found here /home/$USER/.ssh I have the follow configurations:

Host ubserver
    Hostname 127.0.0.1
    Port 2222
    User george

Meaning I can simply do:

ssh ubserver

and connect to the said server without typing more than that line in the terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.