简体   繁体   English

更改Windows上git使用的.ssh密钥

[英]Change the .ssh key used by git on windows

I am trying to push a code to a remote repository with which one of my two accounts on github are authorized. 我正在尝试将代码推送到已授权我在github上的两个帐户之一的远程存储库。 Corresponding to the two accounts, I have two ssh keys in my .ssh folder: id_rsa and id_rsa_rahulserver 与这两个帐户相对应,我的.ssh文件夹中有两个ssh密钥:id_rsa和id_rsa_rahulserver

I want to use the second key instead of the first, but whenever I do a git push, I get this messageછ 我想使用第二个键而不是第一个键,但是每当我执行git push时,我都会收到此消息છ

Enter passphrase for key '/c/Users/rahul/.ssh/id_rsa':

So always its taking up the first key instead of second(thereby giving the not authorized error). 因此,它总是占用第一个密钥而不是第二个密钥(从而给出未经授权的错误)。 What should I do to make it accept second key instead of first for git push? 我应该怎么做才能使其接受第二个密钥而不是git push的第一个密钥?

create a file ' config ' in .ssh/ if you don't have it already and add the following .ssh/创建文件“ config ”(如果尚未创建),并添加以下内容

Host github.com
  IdentityFile ~/.ssh/id_rsa_rahulserver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM