Skip to content

error loading known_hosts: ; class=Ssh (23) when trying to connect to remote. #937

Closed
@tzAcee

Description

@tzAcee

Hey,
I stumble accross an error "error loading known_hosts: ; class=Ssh (23)" when I try to connect to a remote host on our company azure repo.
The git cmd tool works fine of course. So the general SSH configuration should be fine. Seems like the the configuration isn't read out correctly. Do I have to set a config of the repo or something before I connect to the remote?

I wrote a simple test tool for what Im doing:

fn main() { 
   let local_repo_path = r"D:\projects\some_repo_dir"; 
   env::set_var("GIT_SSH_COMMAND", r"ssh -i *ID_RSA_PATH* -o UserKnownHostsFile=*KNOWN_HOSTS_PATH*"); // Added testwise, but it does nothing
   let repo = Repository::open(local_repo_path);
   match repo {
    Ok(repo_unwrap) => {
        let mut remote = repo_unwrap.find_remote("origin").unwrap();
        let res = remote.connect(git2::Direction::Fetch); // also tested connect_auth
        if res.is_err() {
            println!("Could not connect {}", res.err().unwrap());
        }
        },
        Err(_) => println!("Could not open Repo."),
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions