Non-default location for ssh config file in Linux
Non-default location for ssh config file in Linux
How can I tell ssh
to look for config file in a location other than the default one: ~/.ssh/config
?
ssh
~/.ssh/config
2 Answers
2
-F configfile
Specifies an alternative per-user configuration file. If a configuration file is given on the command line, the system-wide configuration file (/etc/ssh/ssh_config) will be ignored. The default for the per-user configuration file is ~/.ssh/config.
Source: https://linux.die.net/man/1/ssh
@motam79 quoting: "[...] the system-wide configuration file (/etc/ssh/ssh_config) will be ignored.". Without system-wide file, you can't store this anywhere. (This is my own assumption without any hard evidence and testing!)
– Ismael Miguel
Sep 12 '18 at 8:37
@motam79 If you're only starting ssh manually from the command line, you can make a shell alias. If you use other stuff (scripts, binaries, whatever) that look for ssh on the path, you could drop a wrapper script somewhere that has a higher priority than the real binary.
– pt314
Sep 12 '18 at 10:40
As of OpenSSH 7.3p1, you can Include other config files in ssh_config.
So, you could add to /etc/ssh/ssh_config:
Include ~/custom_ssh.conf
Don't think this will stop the default ~/.ssh/config from being loaded, however.
Thanks for contributing an answer to Super User!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
This works but every time I need to enter the config file path. Is it possible to store this option as default somewhere?
– motam79
Sep 12 '18 at 2:34