By default the ssh config file is ~/.ssh/config, but for some historical reason, there already have a directory ~/.ssh/config/, so I want to change the ssh config file name or location, so my ssh can pick the new config file up.
I already tried ssh -F /path/to/configfile, but this will require me to run ssh command each time, I am expecting a persistent configuration, so that it can be affected by other ssh related commands as well, such as git.
The SSH server has its own set of configuration files, including the SSH server system-wide configuration file named sshd_config. By default, these files reside in the /etc/ssh directory on the remote host.
Copying this answer found on SuperUser :
GIT_SSH_COMMAND:From Git version 2.3.0, you can use the environment variable GIT_SSH_COMMAND like this:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example" git clone example
Note that -i can sometimes be overridden by your config file, in which case, you should give SSH an empty config file, like this:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example -F /dev/null" git clone example
core.sshCommand:From Git version 2.10.0, you can configure this per repo or globally, so you don't have to set the environment variable any more!
git config core.sshCommand "ssh -i ~/.ssh/id_rsa_example -F /dev/null"
git pull
git push
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With