From host B I can SSH various other hosts (C, D) without using any password as I put the public key in the correspondent authorized_keys files (in hosts C and D).From host A I can SSH host B (via password authentication). However, once I am logged into host B I need to authenticate my key each time when I connect to C and D (even if in principle this should not be the case).To summarize, if I connect directly to host B (e.g office) I do not need to type any password to connect to C or D. If I connect to A (e.g. home) and then from A I connect to B, once I am in B I need passwords to connect to D or C. I can partially solve the problem by adding the password to an ssh-agent (using ssh-add), but every time I open a new shell in B I need to do this again.UpdateThanks to the useful comments, it turned out that the problem is the following. When I connect directly to B there is a keyring program running (in my specific case this is seahorse). Therefore the passwords of all encrypted private keys can be used automatically. When I connect to B from A this does not happen. For a mysterious reason even if I start a remote session (vnc / remmina) from A to B the program seahorse is not active in B and hence I have to manually insert the passwords over and over.I installed keychain and the problem has been solved.However, I am not sure if it is worth to encrypt a private key which is only used for SSH connection to a specific server. Is there any concrete security risk by not encrypting the private keys? In principle if one is able to access the private key he/she is also able to use the passwords stored in the keychain...so it seems that there might not be a big advantage in encrypting the private keys.
Why do I need to insert the passphrase for an RSA key on a remote host after SSH?
ssh;key authentication;ssh agent
You solved part of your issue with the use of keychain to act as storage for your passphrases for your SSH keys. As to your other question:However, I am not sure if it is worth to encrypt a private key which is only used for ssh connection to a specific server. Is there any concrete security risk by not encrypting the private keys? In principle if one is able to access the private key he/she is also able to use the passwords stored in the keychain...so it seems that there might not be a big advantage in encrypting the private keysIt's not that your private keys are left unencrypted, it's that they're not protected with a passphrase. Therefore anyone that can gain access to your home directory's .ssh directory can get control of your SSH keys without issue. If you're comfortable with leaving these keys on a system that you have full control over then I see no issue with leaving them as passphrase-less. I would also recommend generating a different set of keys that you can leave on secondary systems such as this, or even a unique set just for this server, so that you can completely abandon it without much issue if you ever discover its been compromised.As to using keychain to manage your keys, I see not much to be gained with having passphrases on SSH keys if you're using keychain to manage them, except that keychain will only store them when you use them. If you don't use the keys often, and are diligent about cleaning up keychain when you're finished, then a passphrase would be an advantage, but IMO, it's a small one.