diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
index fb2038b8629f8d66a9bf7c24accc13c12e08f15a..d73e2055a50aed3cf5626094f970e1fa9e4c5f70 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
@@ -147,17 +147,25 @@ private String commandFor(final String exe) {
 	ChannelExec exec(final String exe) throws TransportException {
 		initSession();
 
-		final int tms = getTimeout() > 0 ? getTimeout() * 1000 : 0;
 		try {
 			final ChannelExec channel = (ChannelExec) sock.openChannel("exec");
 			channel.setCommand(commandFor(exe));
-			channel.connect(tms);
 			return channel;
 		} catch (JSchException je) {
 			throw new TransportException(uri, je.getMessage(), je);
 		}
 	}
 
+	private void connect(ChannelExec channel) throws TransportException {
+		try {
+			channel.connect(getTimeout() > 0 ? getTimeout() * 1000 : 0);
+			if (!channel.isConnected())
+				throw new TransportException(uri, "connection failed");
+		} catch (JSchException e) {
+			throw new TransportException(uri, e.getMessage(), e);
+		}
+	}
+
 	void checkExecFailure(int status, String exe, String why)
 			throws TransportException {
 		if (status == 127) {
@@ -235,14 +243,13 @@ class SshFetchConnection extends BasePackFetchConnection {
 				setMessageWriter(msg);
 
 				channel = exec(getOptionUploadPack());
-				if (!channel.isConnected())
-					throw new TransportException(uri, "connection failed");
 
 				final InputStream upErr = channel.getErrStream();
 				errorThread = new StreamCopyThread(upErr, msg.getRawStream());
 				errorThread.start();
 
 				init(channel.getInputStream(), outputStream(channel));
+				connect(channel);
 
 			} catch (TransportException err) {
 				close();
@@ -304,14 +311,13 @@ class SshPushConnection extends BasePackPushConnection {
 				setMessageWriter(msg);
 
 				channel = exec(getOptionReceivePack());
-				if (!channel.isConnected())
-					throw new TransportException(uri, "connection failed");
 
 				final InputStream rpErr = channel.getErrStream();
 				errorThread = new StreamCopyThread(rpErr, msg.getRawStream());
 				errorThread.start();
 
 				init(channel.getInputStream(), outputStream(channel));
+				connect(channel);
 
 			} catch (TransportException err) {
 				close();