failed to authenticate SSH session
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 20/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- git, github, rust
调研方向
先从 issue 中所示的 credentials callback 和 git2::Cred::ssh_key 调用开始,然后检查 push 使用的 SSH 远程仓库和密钥路径。报告中没有指定文件或测试;完成的标准是报告中的 push 能够在不出现 SSH 会话错误的情况下完成身份验证。
由索引模型根据 Issue 内容生成。
描述
I am trying to push to a github repo using the ssh remote but I am getting an error
failed to authenticate SSH session: ; class=Ssh (23)
the code
fn push(repo_location: &str, origin: &str) {
let repo = Repository::open(repo_location).unwrap();
let mut origin = repo.find_remote(&origin).unwrap();
let branch = repo.find_branch(&"main", BranchType::Local).unwrap();
let branch_ref = branch.into_reference();
let branch_ref_name = branch_ref.name().unwrap();
repo.set_head(branch_ref_name).unwrap();
let mut remote_callbacks = git2::RemoteCallbacks::new();
remote_callbacks.credentials(|_url, _username_from_url, _allowed_types| {
match git2::Cred::ssh_key(
_username_from_url.unwrap(),
// Some(std::path::Path::new("<home>/.ssh/github/id_rsa.pub")),
None,
std::path::Path::new("<home>/.ssh/github/id_rsa"),
None,
) {
Ok(cred) => {
println!("credential creation success");
Ok(cred)
}
Err(e) => {
println!("credential creation Failed: {:#?}", e);
Err(e)
}
}
});
let mut push_options = git2::PushOptions::new();
let mut_push_options = push_options.remote_callbacks(remote_callbacks);
match origin.push(&[branch_ref_name], Some(mut_push_options)) {
Ok(_) => {
println!("push-pushed to remote")
}
Err(e) => {
println!("push-failed to push to remote: {}", e)
}
};
}
and I am getting this output
and I am able to read the key file
can anyone help?
- 主要语言
- 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 于 44 天前认领。 未关闭
难度 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
-
Thai project names become 'project', 'project-2'… (slug keeps ASCII only)可能已有人在做 @mastel2 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
storytold/craft-anything#2538 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
compiler-explorer/compiler-explorer#9738 ·
维护者通常 2 天内回复
-
area: runtime enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 84/100
hffgzktbcc-blip/ounce-core#663 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
zellij-org/zellij#6026 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
tamatebako/tebako#1155 ·
维护者通常 1 天内回复