Question about remote clone
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- docker, git, rust
- 领域
- networking
调研方向
首先使用 Rust 示例、docker-compose.yml 和 Dockerfile 重现 SSH 克隆,然后检查报告的 libssh2 remote.c 失败。将 Rust/libgit2 路径与终端中正常工作的 Git 路径进行比较,并确定问题是在容器的 SSH 设置中还是在依赖项中;完成的标准是得出可复现的诊断和可执行的解决方案。
由索引模型根据 Issue 内容生成。
描述
Overview
The provided documentation for cloning with an SSH key closely follows the code below. I keep getting an authentication error even after trying most of the closed-issue solutions in this repository. I suspect that the error is coming from libssh2 dependency because when I trace the bug it appears to be erroring out in remote.c.
The SSH key does work with the environment because it clones properly when using git in terminal
Error
Failed to clone: failed to start SSH session: Unable to exchange encryption keys; class=Ssh (23) 😡
Code
Rust Code
use git2::{build::RepoBuilder, Cred, Error, FetchOptions, RemoteCallbacks, Repository};
use std::env;
use std::path::Path;
fn main() {
let url = "ssh://git@localhost:2222/home/git/repos/test.git";
let path = Path::new("./test");
let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|_url, username_from_url, _allowed_types| {
Cred::ssh_key(
username_from_url.unwrap(),
None,
std::path::Path::new(&format!("{}/.ssh/id_rsa", env::var("HOME").unwrap())),
None,
)
});
let mut fetch_options = FetchOptions::new();
fetch_options.remote_callbacks(callbacks);
let mut builder = RepoBuilder::new();
builder.fetch_options(fetch_options);
match builder.clone(&url, &path) {
Ok(repo) => println!("Successfully cloned into {}", repo.path().display()),
Err(e) => println!("Failed to clone: {}", e),
}
}
Enviroment
- Client (Me): Windows 11
- Git Server: Docker Container with ubuntu (see docker-compose below)
docker-compose.yml
services:
git-server:
build: .
ports:
- "2222:22"
volumes:
- ./ssh:/home/git/.ssh
dockerfile
FROM ubuntu:latest
# Update and install git and openssh-server
# Create the directory for the sshd server
RUN apt-get update && \
apt-get install -y git openssh-server && \
mkdir /var/run/sshd
# Switch to the git user and create the .ssh directory with git user permissions
RUN useradd -m git && \
su git -c "mkdir -p ~/.ssh && chmod 700 ~/.ssh && touch ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
# ⚠️ Must add the ssh key to the authorized_keys file see read me for more
RUN chmod 700 /home/git/.ssh && \
chmod 600 /home/git/.ssh/authorized_keys
RUN chown -R git:git /home/git/.ssh
# Create a folder for the git repositories
RUN su git -c "mkdir /home/git/repos"
# Create a test repository
RUN su git -c "cd /home/git/repos && git init --bare test.git"
# Expose the ssh port
EXPOSE 22
# Start the sshd server
CMD ["/usr/sbin/sshd", "-D"]
SSH key creation
ssh-keygen -t rsa -b 4096 -C "[email protected]"
I then put this key in the mount .ssh folder and put it in a file called authorized_keys.
Final Remark
I am just trying to get a test environment for a server set up so I can test it with my actual application. If anyone has an alternative approach.
- 主要语言
- Rust
- 星标
- 2.1k
- 派生
- 470
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 18
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rust-lang/git2-rs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
`stash_foreach` crashes on stash entries with no message or a non-UTF-8 message可能已有人在做 @shivampwm2020 于 43 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 64/100
维护者通常 1 天内回复
查看 rust-lang/git2-rs 的全部 Issue
相似的 Issue
-
bug P2
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
Windows microphone listing treats words in a device name as DirectShow labels可能已有人在做 @Sujal-chaudhary 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 88/100
clipy-recorder/clipy#447 · 2 条评论 ·
维护者通常 1 天内回复
-
nightly-cleanup
难度 2/5 1-3 小时 新手友好度 78/100
max-sixty/worktrunk#4939 · 1 个 reaction ·
维护者通常 1 天内回复
-
flaky
难度 2/5 1-3 小时 新手友好度 68/100
stacks-network/stacks-core#7918 · 1 条评论 ·
维护者通常 2 天内回复