From 5c74cc79b5df7a2bb389c080136cccd9099fbb4b Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Sun, 21 Apr 2024 19:32:02 +0100 Subject: [PATCH 1/2] Allow SSH remotes to use any port --- crates/gitbutler-core/src/ssh.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/gitbutler-core/src/ssh.rs b/crates/gitbutler-core/src/ssh.rs index ea75d2eb8..54546e8af 100644 --- a/crates/gitbutler-core/src/ssh.rs +++ b/crates/gitbutler-core/src/ssh.rs @@ -27,9 +27,12 @@ pub fn check_known_host(remote_url: &git::Url) -> Result<(), Error> { return Ok(()); }; + let port = remote_url.port.as_ref().unwrap_or(&22); + let mut session = ssh2::Session::new().map_err(Error::Ssh)?; - session - .set_tcp_stream(std::net::TcpStream::connect(format!("{}:22", host)).map_err(Error::Io)?); + session.set_tcp_stream( + std::net::TcpStream::connect(format!("{}:{}", host, port)).map_err(Error::Io)?, + ); session.handshake().map_err(Error::Ssh)?; let mut known_hosts = session.known_hosts().map_err(Error::Ssh)?; From 76556eb6c8038e20a300d9804179db55267163db Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Sun, 21 Apr 2024 22:45:00 +0100 Subject: [PATCH 2/2] Remove useless reference --- crates/gitbutler-core/src/ssh.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/gitbutler-core/src/ssh.rs b/crates/gitbutler-core/src/ssh.rs index 54546e8af..16abff072 100644 --- a/crates/gitbutler-core/src/ssh.rs +++ b/crates/gitbutler-core/src/ssh.rs @@ -27,7 +27,7 @@ pub fn check_known_host(remote_url: &git::Url) -> Result<(), Error> { return Ok(()); }; - let port = remote_url.port.as_ref().unwrap_or(&22); + let port = remote_url.port.unwrap_or(22); let mut session = ssh2::Session::new().map_err(Error::Ssh)?; session.set_tcp_stream(