Question: 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?

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

```
There is `~/.ssh/config` as pointed out in the manual pages for [`ssh`](http://manpages.ubuntu.com/manpages/lucid/man1/ssh.1.html). It is well described there and in `man ssh_config` and also many times answered on askubuntu.

TL;DR:

```
# to preserve connections:
ControlMaster auto
ControlPath ~/.ssh/controlmasters/%r@%h:%p
ControlPersist 20m

# to provide correct keys, users, IPs and use aliases
Host yourHost
  Hostname IPaddress
  User user1
  IdentityFile ~/.ssh/id_ecdsa

Host yourSecondHost
  Hostname IP2
  User user2
  IdentityFile ~/.ssh/id_rsa

```

If you don't want to write passphrases, there is `ssh-agent`, where you can add the keys for your session:

```
eval `ssh-agent`
ssh-add ~/.ssh/id_ecdsa
# insert passphrase once
ssh yourHost
# will ask only for password
# next ssh connections will not ask for 

```