diff --git a/src/libs/utils/ssh/sshchannel.cpp b/src/libs/utils/ssh/sshchannel.cpp
index 4fa68dc89e318911f8625249c7eb4eef0827d2d1..a6a864095c5aa1e98cd18e2c2cd3516d0dcbb9fa 100644
--- a/src/libs/utils/ssh/sshchannel.cpp
+++ b/src/libs/utils/ssh/sshchannel.cpp
@@ -116,8 +116,8 @@ void AbstractSshChannel::handleWindowAdjust(quint32 bytesToAdd)
 
 void AbstractSshChannel::flushSendBuffer()
 {
-    const quint32 bytesToSend
-        = qMin<quint32>(m_remoteWindowSize, m_sendBuffer.size());
+    const quint32 bytesToSend = qMin(m_remoteMaxPacketSize,
+        qMin<quint32>(m_remoteWindowSize, m_sendBuffer.size()));
     if (bytesToSend > 0) {
         const QByteArray &data = m_sendBuffer.left(bytesToSend);
         m_sendFacility.sendChannelDataPacket(m_remoteChannel, data);
@@ -147,7 +147,8 @@ void AbstractSshChannel::handleOpenSuccess(quint32 remoteChannelId,
 #endif
    m_remoteChannel = remoteChannelId;
    m_remoteWindowSize = remoteWindowSize;
-   m_remoteMaxPacketSize = remoteMaxPacketSize;
+   m_remoteMaxPacketSize = remoteMaxPacketSize - sizeof(quint32) - sizeof m_remoteChannel - 1;
+        // Original value includes packet type, channel number and length field for string.
    setChannelState(SessionEstablished);
    handleOpenSuccessInternal();
 }
diff --git a/src/libs/utils/ssh/sshoutgoingpacket.cpp b/src/libs/utils/ssh/sshoutgoingpacket.cpp
index 2262fcd1ca77cbb93f6cbeb7e8a4c89a255f1087..d17b9003213299e0e7a62922514ef1df916a0f9d 100644
--- a/src/libs/utils/ssh/sshoutgoingpacket.cpp
+++ b/src/libs/utils/ssh/sshoutgoingpacket.cpp
@@ -297,6 +297,9 @@ void SshOutgoingPacket::finalize()
     qDebug("Encrypting packet of type %u", m_data.at(TypeOffset));
 #endif
     encrypt();
+#ifdef CREATOR_SSH_DEBUG
+    qDebug("Sending packet of size %d", rawData().count());
+#endif
     Q_ASSERT(isComplete());
 }