There are endless number of helpful articles and answers on how set up ~/.ssh/config (e.g., this one's pretty good), but none of them mentions what to do if the private key is also password protected.
1 Answer
Create
~/.ssh/configfile containing one or more entries along the lines of:Host your_server_name HostName 1.2.3.4 Port 22 User your_username IdentityFile ~/.ssh/your_private_key Host another_server HostName 4.5.6.7 Port 22 User another_usernameThe private key for
another serverrequires a password, so theIdentityFileline can be omitted asssh-agentwill be used:Set the proper permissions on
~/.ssh/config:chmod 600 ~/.ssh/configStart
ssh-agent:eval "$(ssh-agent -s)"Add private key with password:
ssh-add ~/.ssh/private_key_for_another_serverIn Midnight Commander, click
LeftorRight>Shell link...and enter "another_server" (or whatever name was given in
~/.ssh/config).
If everything looks right, but MC still refuses to connect, make sure that the private keys also have stricter permissions. On several occasions, I copied the private keys to a new "jump" server, but nothing happened, and just needed some chmod 600.
This answer is mostly a combination of:
the article Midnight Commander remote connect via Shell link (copy files over SSH) and SFTP link using FISH and public key authentication, and
The article has lot of pictures and other examples, too.