git Permission denied(publickey),在每个连接上 [英] git Permission denied (publickey), on every connect
问题描述
我试图用git来简化我的工作,然后我试着把我的存储库与
git pull
我得到Permission denied(publickey),我通过两条命令解决了这个问题:
1. ssh-agent / bin / bash
2. ssh-add /root/.ssh/mykey
为/root/.ssh/mukey * 输入密码短语 - 现在我使用git pull
然后我通过ssh连接下一次我必须重复输入这两个命令
如何使它会自动初始化跳过这一步?
您应该拥有: 一个ssh配置文件,指定您的ssh连接的所有详细信息。 添加代理和<$ c在
cat 〜/ .ssh / config
$
主机yourserver
主机名upstream.server.com
用户git#或用于服务器的正确用户帐户
IdentityFile / root /.ssh/mykey
$ g $ git remote set -p $ p $ g $ g $ g $ g $ g $ g $ g $ g $ g $ g $ g $ g $ g $ g $ g $ gg remote set- url origin ssh:// yourserver:yourRepo.git
.bashrc
或 .profile
中使用$ c> ssh-add 命令。
- 例如,在通过SSH配置Git 。
-
- 将一个名为.bashrc的文件添加到您的主文件夹 li>
-
打开文件并粘贴:
#! / bin / bash
eval`ssh-agent -s`
ssh-add /root/.ssh/mykey
- 将一个名为.bashrc的文件添加到您的主文件夹 li>
I try to simplify my work with git, then i try to pull my repository with
git pull
i get "Permission denied (publickey), i solve this by two commands:
1. ssh-agent /bin/bash
2. ssh-add /root/.ssh/mykey
Enter passphrase for /root/.ssh/mukey * - now i cat use "git pull"
but then i connect next time via ssh i must reenter this two commands again and again
how to make it auto init to skip this steps ?
You should have:
an ssh config file specifying all the details of your ssh connection.
cat ~/.ssh/config Host yourserver Hostname upstream.server.com User git # or the right user account to use on your server IdentityFile /root/.ssh/mykey
change the remote url
git remote set-url origin ssh://yourserver:yourRepo.git
add the agent and
ssh-add
command in your.bashrc
or.profile
.- One approach is described, for instance, in "Configuring Git over SSH".
Another approach in "How to run (git/ssh) authentication agent?"
- Add a file called .bashrc to your home folder
Open the file and paste in:
#! /bin/bash eval `ssh-agent -s` ssh-add /root/.ssh/mykey
这篇关于git Permission denied(publickey),在每个连接上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!