failed to authenticate SSH session
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 450
- Avg merge
- 11m
- Merged PRs (30d)
- 1
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the credentials callback and the git2::Cred::ssh_key call shown in the issue, then check the SSH remote and key path used by the push. There is no file or test named in the report; done means the reported push authenticates without the SSH session error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github, rust
- Domain
- authentication, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100