Setting the default ssh key location

前端 未结 2 999
抹茶落季
抹茶落季 2020-12-23 09:19

ssh will look for its keys by default in the ~/.ssh folder. I want to force it to always look in another location.

The workaround I\'m using is to add the keys from

相关标签:
2条回答
  • 2020-12-23 09:27

    If you are only looking to point to a different location for you identity file, the you can modify your ~/.ssh/config file with the following entry:

    IdentityFile ~/.foo/identity
    

    man ssh_config to find other config options.

    0 讨论(0)
  • 2020-12-23 09:49

    man ssh gives me this options would could be useful.

    -i identity_file Selects a file from which the identity (private key) for RSA or DSA authentication is read. The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro- tocol version 2. Identity files may also be specified on a per- host basis in the configuration file. It is possible to have multiple -i options (and multiple identities specified in config- uration files).

    So you could create an alias in your bash config with something like

    alias ssh="ssh -i /path/to/private_key"

    I haven't looked into a ssh configuration file, but like the -i option this too could be aliased

    -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.

    0 讨论(0)
提交回复
热议问题