我已经安装了SSH Agent Plugin以使用ssh身份验证来提取git存储库.我想使用位于系统文件中的ssh键(来自Jenkins master~/.ssh选项).它是从官方插件页面截取的截图
不幸的是我没有看到这个选项.我只能选择"直接输入".请查看我的截图.
我配置错了吗?
我想知道我是否可以获得一些帮助。我最近重新安装了操作系统,但遇到了一个以前从未遇到过的奇怪问题。我正在按照Github 步骤添加 ssh 代理
基本上,每次登录时我都需要运行
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_personal
Run Code Online (Sandbox Code Playgroud)
当我重新启动计算机时。
当我尝试跑步时,git clone X我得到了
Cloning into 'X'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
但在我运行上述两个命令后,我可以很好地克隆
注意:Gitlab 也存在问题。抱歉,我应该明确的
我一直在将 ssh-agent 转发到 docker 容器(使用我的 docker-compose 安装)时遇到了严重的麻烦。我有运行 Catalina 的 Mac,使用 docker-engine 19.03.8 和 Compose @ 1.24。以下是我的 docker-compose 文件:
version: '3.7'
services:
platform:
build:
context: .
dockerfile: ./platform/compose/Dockerfile.platform.local
working_dir: /root/platform
ports:
- "3000:3000"
command: ["./compose/scripts/start_rails.sh"]
tty: true
stdin_open: true
volumes:
- type: bind
source: /run/host-services/ssh-auth.sock
target: /run/host-services/ssh-auth.sock
env_file: ./platform/.env
environment:
TERM: xterm-256color
SSH_AUTH_SOCK: /run/host-services/ssh-auth.sock
volumes:
Run Code Online (Sandbox Code Playgroud)
我配置 ssh-agent 转发的方式在docker-compose 文档中指定
该./compose/scripts/start_rails.sh脚本确实bundle install && bundle exec rails s。我从私有存储库中提取的 gem 很少,我认为我应该能够通过转发 ssh-agent 来安装这些 gem。
我还尝试在旋转 docker-compose 之前启动 ssh-agent,但这似乎没有任何作用。 …
我想让我的个人服务器成为我的主要git远程并自动镜像到github.我发现这篇文章主要使用一个post-receive脚本git push --mirror(基本上).
我的方法不同之处在于我希望避免创建和保护部署密钥,然后在每个存储库上配置它.
我的post-receive脚本与注释中标记的大多数变体一起正常工作,除非我在上面的博客文章中执行完整的nohup + stdio重定向+后台处理,身份验证停止工作.
GITHUB_USERNAME=focusaurus
BARE_PATH=$(pwd -P)
REPO_NAME=$(basename "${BARE_PATH}")
REPO_URL="ssh://git@github.com/${GITHUB_USERNAME}/${REPO_NAME}"
echo "About to mirror to ${REPO_URL}"
#hmm, this works
#git push --mirror "${REPO_URL}"
#this works, too
#nohup git push --mirror "${REPO_URL}"
#and this also works OK
nohup git push --mirror "${REPO_URL}" &
#but this fails with
#Permission denied (publickey).
#fatal: The remote end hung up unexpectedly
#Somehow ssh agent forwarding must get screwed up? Help me, Internet.
#nohup git push --mirror …Run Code Online (Sandbox Code Playgroud) OS Description: Ubuntu 14.04.3 LTS
ssh: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3, OpenSSL 1.0.1f 6 Jan 2014
Run Code Online (Sandbox Code Playgroud)
我无法为gitlab使用多个ssh密钥.我得到的错误是
GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我非常确定我做的一切都是正确的这是我的配置文件
Host work gitlab.com
Hostname gitlab.com
IdentityFile ~/.ssh/ida_rsa
User git
Host integrate gitlab.com
Hostname gitlab.com
IdentityFile ~/.ssh/ida_rsa_personal
User git
Run Code Online (Sandbox Code Playgroud)
密钥在ssh-agent中自动添加,但为了确保我还手动添加了密钥
$ ssh-add -l
2048 e7:08:d6:8c:00:28:31:f9:3f:21:4a:0f:4e:1e:ee:20 id_rsa (RSA)
2048 ff:22:f6:90:2b:7c:9f:ed:45:41:df:79:06:de:fe:81 id_rsa_personal (RSA)
Run Code Online (Sandbox Code Playgroud)
我的ssh-agent也在运行
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-uTC6tA5HMt1x/agent.4899; …Run Code Online (Sandbox Code Playgroud) 我ssh在我的应用程序中使用命令运行 shell 脚本。使用的私钥是通过密码加密的,问题是 - 当被问到时我无法交互地传递它。密钥没有添加到ssh-agent. 我无法执行,ssh-add my_key因为密码应该以交互方式传递。对终端通信有好处,但在应用内部使用不太好。
该man page说:
显示和 SSH_ASKPASS
如果 ssh-add 需要密码短语,如果它是从终端运行的,它将从当前终端读取密码短语。如果 ssh-add 没有与之关联的终端,但设置了 DISPLAY 和 SSH_ASKPASS,它将执行 SSH_ASKPASS 指定的程序并打开 X11 窗口以读取密码。这在从 .xsession 或相关脚本调用 ssh-add 时特别有用。(请注意,在某些机器上,可能需要重定向来自 /dev/null 的输入才能使其工作。)
当我执行时,SSH_ASKPASS=file_with_passphrase ssh-add my_key我仍然要求输入密码,在这种情况下,看起来 env var 只是被忽略了。我尝试执行ssh -o BatchMode=yes并且服务器拒绝了编码的密钥,因为没有人能够对其进行解码。
我绝对可以在使用之前手动解码 ssh 密钥,ssh-agent但看起来我即将从SSH_ASKPASS变量中获得我需要的东西,但我不知道如何使它工作。很高兴得到社区帮助。
首先,我试图让织物工作,但它一直在问我密码.
所以我试图减少这个问题.也许从Python创建SSH连接是一个很好的POC.我发现Fabric使用parmiko进行SSH处理.嗯.好吧,让我们尝试一个工作的例子.
这是我写的.
from ssh import *
import os
print "SSH-AGENT VARS"
print "SSH_AGENT_PID: %s " % os.environ['SSH_AGENT_PID']
print "SSH_AUTH_SOCK: %s " % os.environ['SSH_AUTH_SOCK']
a = Agent()
keys=a.get_keys()
print keys.count("192.168.1.10")
client = SSHClient()
client.load_system_host_keys()
client.connect('192.168.1.10')
Run Code Online (Sandbox Code Playgroud)
导致以下错误消息:
% ./ssh_test.py
SSH-AGENT VARS
SSH_AGENT_PID: 26557
SSH_AUTH_SOCK: /tmp/ssh-pZHBElj26556/agent.26556
0
Traceback (most recent call last):
File "./ssh_test.py", line 18, in <module>
client.connect('192.168.1.10')
File "/usr/local/lib/python2.7/dist-packages/ssh/client.py", line 332, in connect
self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
File "/usr/local/lib/python2.7/dist-packages/ssh/client.py", line 493, in _auth
raise saved_exception
ssh.PasswordRequiredException: Private key …Run Code Online (Sandbox Code Playgroud) 尝试将Git与Cygwin一起使用时遇到问题.我已经生成并添加了ssh密钥到GitLab服务器,一切都可以正常通过MINGW64(克隆,拉动等),但我想使用Cygwin并发现它不起作用.
虽然我已将生成的密钥的副本放到〜/ user/.ssh文件夹并手动添加密钥,但"ssh-add -l"会将其打印在列表中,但是当我尝试获取存储库(或任何其他服务器)时命令)我得到:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
它看起来像一个bug,但可能我做错了什么.有没有人遇到这个问题?谢谢.
更新:在Cygwin中更新OpenSSH版本后,问题已经消失.
本地操作系统:Windows 10 Pro(使用 Git Bash 作为我的终端)
暂存服务器操作系统:Ubuntu 16.04 LTS
我一直在努力让基本的 Capistrano 部署在我的登台服务器上工作。我按照本指南设置了 Capistrano。
git:check由于据称无权访问我在 GitLab上的存储库,部署过程总是在舞台上失败。我确信我的 SSH 代理转发工作正常,因为我能够通过 SSH 连接到我的服务器并使用我的 SSH 密钥访问 GitLab。SSH 密钥未存储在我服务器上的任何位置:
$ ssh deploy@myserver.com
deploy@MyServer:~$ ssh -T git@gitlab.com
debug1: client_input_channel_open: ctype auth-agent@openssh.com rchan 2 win 65536 max 16384
debug1: channel 1: new [authentication agent connection]
debug1: confirm auth-agent@openssh.com
Welcome to GitLab, Alexander!debug1: channel 1: FORCE input drain
Run Code Online (Sandbox Code Playgroud)
到目前为止,关于这个问题的所有问题都没有对我有用。
这是我的部署文件:
部署文件
set :application, "myapp"
set :branch, "master"
set :repo_url, "git@gitlab.com:MyApp/myapp.git"
# Defaults to false
# Skip …Run Code Online (Sandbox Code Playgroud) 我收到错误“错误:无法运行 ssh-add” 我正在尝试通过 ssh 进入远程机器,所以
SSH 凭据已设置
管道脚本正在调用 ssh-agent
在执行作业时,我收到以下错误

我已经尝试过这个报告的错误https://issues.jenkins-ci.org/browse/JENKINS-50181但它不起作用并且错误已经在我现在拥有的最新版本 1.17 中得到解决。任何人都可以建议如何解决这个问题。