src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.9k stars 541 forks source link

restricted /etc/ssh/ssh_known_hosts break fetch or push with ssh #1079

Open clarsonneur opened 5 years ago

clarsonneur commented 5 years ago

Hi,

Thank you for this project! It is really great!

On my Fedora workstation, the /etc/ssh/ssh_known_hosts is readable by root only. Don't ask me why. It is a fact and git push or git fetch in this context works great either.

So, I expect that go-git with push/fetch and ssh transport should behave the same.

So, I believe we should update https://github.com/src-d/go-git/blob/master/plumbing/transport/ssh/auth_method.go#L279 to test on readable rights as well. Currently, filterKnownHostsFiles check on files existence only. I think we should add a check that the file is also readable.

Any thoughts?

I can create a PR for that.

Thanks

jfontan commented 5 years ago

You're correct. That file should be filtered out if it cannot be read. PR is appreciated.

clarsonneur commented 5 years ago

ok. I will update it.