import org.apache.sshd.sftp.common.SftpException;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.errors.TransportException;
+import org.eclipse.jgit.internal.transport.ssh.OpenSshConfigFile;
import org.eclipse.jgit.internal.transport.sshd.JGitSshClient;
import org.eclipse.jgit.internal.transport.sshd.SshdText;
import org.eclipse.jgit.transport.FtpChannel;
JGitSshClient.LOCAL_FORWARD_ADDRESS,
portForward.getBoundAddress());
}
- resultSession = connect(hostConfig, context, timeout);
+ int timeoutInSec = OpenSshConfigFile.timeSpec(
+ hostConfig.getProperty(SshConstants.CONNECT_TIMEOUT));
+ resultSession = connect(hostConfig, context,
+ timeoutInSec > 0 ? Duration.ofSeconds(timeoutInSec)
+ : timeout);
if (proxySession != null) {
final PortForwardingTracker tracker = portForward;
final ClientSession pSession = proxySession;
/** Key in an ssh config file. */
public static final String CONNECTION_ATTEMPTS = "ConnectionAttempts";
+ /**
+ * An OpenSSH time value for the connection timeout. In OpenSSH, this
+ * includes everything until the end of the initial key exchange; in JGit it
+ * covers only the underlying TCP connect.
+ *
+ * @since 6.1
+ */
+ public static final String CONNECT_TIMEOUT = "ConnectTimeout";
+
/** Key in an ssh config file. */
public static final String CONTROL_PATH = "ControlPath";