Ubuntu – How to save SSH options and connections in Ubuntu?

networkingpasswordserverssh

I have at this time two remote machines to which I am connecting. For one I am using private key with passphrase, and another one I am using root password.

Now, when I want to connect to machine with root password authentication, first ssh asks me for passphrase for machine which private key is inside my ~/.ssh directory,and then when I enter correct passphrase let me enter password for machine to which I am connectign with root password.

Is there any way to save sessions, and connection options, for example like in Putty?

Best Answer

  • You can use a per-user ssh-config file located in

    ~/.ssh/config
    

    or a system-global one in

    /etc/ssh/ssh_config
    

    that stores the basic settings for each connection.

    Example:

    Host example_host
        User foo
        HostName example.com
        IdentityFile ~/.ssh/foo.key
        Port 23421
    

    Having this in place, calling

    ssh example_host
    

    will open up a ssh-connection to example.com on port 23421, using the user foo and foo.key for authentication.

    For an in-deep explanation, see the man page of ssh:

    man ssh
    

    Don't forget to set proper permissions on the config file:

    chmod 600 ~/.ssh/config