Git and SSH, which key is used?

后端 未结 7 1925
暗喜
暗喜 2021-01-29 23:57

Say your .ssh directory contains 30 keys (15 private and 15 public).

Where in Git can one check which one is used to connect to a given remote repository?

7条回答
  •  醉梦人生
    2021-01-30 00:42

    I'd say most practical to my taste would be:

    GIT_SSH_COMMAND='ssh -v' git …
    

    of course, depending on circumstances it might be beneficial just to export it to current SHELL's environment so that you won't have to prepend it manually each time. Then it'd be this way:

    export GIT_SSH_COMMAND='ssh -v'
    git …
    

    — As man git suggests there're a few of environmental variables that would affect Git's operations with use of SSH. According to man ssh you can get some debugging info when deploying -v option (not only but also, check out the manual if you're curious for more).

    which key is used?

    In the output you would see smth like …

    debug1: Offering public key: …
    

    … which is the answer to your q-n.

提交回复
热议问题