Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ssh default config name or location?

Tags:

git

ssh

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.

like image 403
Jakim Avatar asked Feb 24 '17 06:02

Jakim


People also ask

What is the default location for storing SSH configuration files?

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.


1 Answers

Copying this answer found on SuperUser :

Environment variable 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

Configuration 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
like image 155
2 revs Avatar answered Sep 21 '22 18:09

2 revs