Win7 Git bash 出现Permission denied (publickey)错误
来源:互联网 发布:淘宝客服接待流程 编辑:程序博客网 时间:2024/04/30 16:12
Windows用户的多数程序员喜欢安装Git bash,用命令行控制。最近发现如果要操作多个git repos,需要生成多个MD5密钥。在执行git操作时需要指定使用哪个密码,通过以下设置可以实现。
Check that you are connecting to the correct server
使用下面的命令检查是否连接到正确的domain:
$ ssh -vT ssh -vT git@github.comOpenSSH_7.1p2, OpenSSL 1.0.2h 3 May 2016debug1: Reading configuration data /c/Users/Amy Zhao/.ssh/configdebug1: Reading configuration data /etc/ssh/ssh_configdebug1: Connecting to github.com [192.30.253.112] port 22.debug1: Connection established.debug1: key_load_public: No such file or directorydebug1: identity file /c/Users/Amy Zhao/.ssh/id_rsa type -1debug1: key_load_public: No such file or directory...
Always use the “git” user
All connections must be made as the “git” user. If you try to connect with your GitHub username, it will fail:
$ ssh -T billy.anyteen@github.comPermission denied (publickey)
Instead, you should verify your connection by typing:
$ ssh -T git@github.comHi your_username! You've successfully authenticated, but GitHub does not provide shell access.
Make sure you have a key that is being used
First, you should turn on ssh-agent:
# start the ssh-agent in the background$ eval "$(ssh-agent -s)"Agent pid 15192
Verify that you have a private key generated and loaded into SSH. If you’re using OpenSSH 6.7 or older, typing:
$ ssh-add -l2048 a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa (RSA)
Or if you’re using OpenSSH 6.8 or newer:
$ ssh-add -l -E md52048 MD5:a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa (RSA)
The ssh-add
command should print out a long string of numbers and letters. If it doesn’t print anything, you’ll need to [generate a new SSH key][generate SSH keys] and associate it the GitHub.
Tip: On most systems the default private keys (~/.ssh/id_rsa, ~/.ssh/id_dsa and ~/.ssh/identity) are automatically added to the SSH authentication agent. You shouldn’t need to run ssh-add path/to/key unless you override the file name when you generate a key.
Auto-launching ssh-agent on Git for Windows
If you want to auto-start ssh-agent and add the private key you wanted, you can config your ~/.bashrc
file like below:
env=~/.ssh/agent.envagent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }agent_start () { (umask 077; ssh-agent >| "$env") . "$env" >| /dev/null ; }agent_load_env# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not runningagent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then agent_start ssh-add ~/.ssh/github-amy ssh-add ~/.ssh/github_rsaelif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then ssh-add ~/.ssh/github-amy ssh-add ~/.ssh/github_rsafiunset env
Tip: If your private keys are not stored in ~/.ssh/id_rsa or ~/.ssh/id_dsa, you must add their paths with the ssh-add command so that your SSH authentication agent knows where to find them. For example: ssh-add ~/.my_other_ssh/id_rsa
Now, when you first run Git Bash, your ssh-agent and identities was started automatically.
The ssh-agent
process will continue to run until you log out, shut down your computer or kill the process.
If you want ssh-agent
to forget your key after some time, you can configure it to do so by running ssh-add -t <seconds>
.
参考
GitHub Help
Working with SSH key passphrases
Error: Permission denied (publickey)
Amy’s Blog
- Win7 Git bash 出现Permission denied (publickey)错误
- git出现错误:Permission denied (publickey).解决方法
- Win7 Git Permission denied (publickey)
- git 时 出现 Permission denied (publickey).
- GIT设置错误:Error: Permission denied (publickey)
- Git - Permission denied (publickey)
- Git - Permission denied (publickey)
- Permission denied (publickey). -- Windows下使用Git Bash显示权限错误
- ec2 git Permission denied (publickey)
- git clone permission denied(publickey)
- git Permission denied (publickey) 问题
- Git Permission denied (publickey) 解决
- git permission denied (publickey) 解决办法
- git clone Permission denied (publickey).
- Git-Error-Permission denied (publickey).
- 解决方案 git@github.com出现Permission denied (publickey)
- 关于Git中SSH出现的Permission denied (publickey)问题
- 解决方案 git@github.com出现Permission denied (publickey)
- Vmware10虚拟机的使用
- gdb调试core时能用i locals看栈变量、函数行(即不出现No symbol table info available)的必要条件: 1. 编译时有-g参数; 2.so库未被strip脱衣服
- cookie实例介绍
- Java集合框架(四)_day18
- android MVVM开发模式(二)
- Win7 Git bash 出现Permission denied (publickey)错误
- Android应用程序获取system权限
- sizeof
- 【Android】子Fragment获取父Fragment
- 显示软键盘时,键盘没有自动弹出
- HDU 5747 BestCoder Round #84 Aaronson (模拟)
- java提高篇之关键字final
- Mini Project #8 - RiceRocks (Asteroids)
- 欢迎使用CSDN-markdown编辑器