Setting a custom path for git private SSH key on linux

后端 未结 5 1477
春和景丽
春和景丽 2021-01-30 17:19

I\'m trying to setup a git client on linux. I uploaded my private key to the machine, and I understand that I should put it in ~/.ssh, but I don\'t have access to that folder.

5条回答
  •  别跟我提以往
    2021-01-30 17:35

    You can achieve that using a ssh config file.

    First create a file inside your ~/.ssh folder named config, you can use some command like the following

    $ nano ~/.ssh/config
    

    Then, the content of the file should have the location of your key based on each host name. for example:

    Host github.com
     IdentityFile ~/myPublicKeyFolder/myGitHubFile
    Host heroku.com
     IdentityFile ~/myPublicKeyFolder/myHerokuFile
    

    So, when git tries to access each host it will follow the rules inside this config file based on the git host your trying to reach

提交回复
热议问题