How to initiate rekey from server by sending data on channel #675
Replies: 5 comments
-
This is one of the reasons not to use Typically, the window size on a chnanel is around 2 MBytes. If you want to send more than that, you need to wait for the peer to increase the window, indicating that is has consumed the data you've sent so far. This is especially important in cases where multiple channels are open at once on a single TCP connection, as it allows a way to limiting how much buffering is needed for individual channels, where TCP can only provide flow control for the connection as a whole. If you goal is to focus on re-keying, you might trying sending a message which is not flow-controlled. For instance, there's a MSG_DEBUG at the connection level that could be used for this, and a def send_debug(self, msg: str, lang: str = DEFAULT_LANG,
always_display: bool = False) -> None:
"""Send a debug message on this connection
This method can be called to send a debug message to the
other end of the connection.
:param msg:
The debug message to send
:param lang:
The language the message is in
:param always_display:
Whether or not to display the message
:type msg: `str`
:type lang: `str`
:type always_display: `bool`
"""
self.logger.debug1('Sending debug message: %s%s', msg,
' (always display)' if always_display else '')
self.send_packet(MSG_DEBUG, Boolean(always_display),
String(msg), String(lang)) Everything sent over the encrypted channel (which is basically everything once the SSH handshake completes) is counted against the rekeying interval/bytes. You wouldn't even necessarily need to open a session to test rekeying. Just opening a connection should be good enough. |
Beta Was this translation helpful? Give feedback.
-
Hi @ronf, `async def main():
` If I use proc.channel.send_packet(MSG_DEBUG, String(chunk.decode('utf-8'))) getting this error on server side ssh_dispatch_run_fatal: Connection from user cli ip port 36754: incomplete message If I use conn.send_debug(chunk) I don't see rekey happening even after sending 40mb data. |
Beta Was this translation helpful? Give feedback.
-
I'm not sure how OpenSSH implements rekeying, but on AsyncSSH at least it is only implemented on bytes being sent. In other words, no matter how many bytes are received by AsyncSSH, it won't trigger rekeying (at least not based on bytes -- it could still trigger based on time). If OpenSSH is similar, sending data to it won't matter. You need to do something that would cause it to send data back to you, and then you should see it trigger when those received bytes are above whatever rekey limit is set. The "incomplete message" error may be because you are trying to write the message to a channel, but it's a connection-level message. Also, it takes a Boolean and two String arguments, not one String as arguments. See the code above in send_debug(). |
Beta Was this translation helpful? Give feedback.
-
I trying to send data from client to server and If rekey threshold(40MB) I want to get a rekey from server. If I keep this I get this error on server side |
Beta Was this translation helpful? Give feedback.
-
You're missing a call to Actually, as I mentioned before, you really shouldn't be sending at the channel level here. That adds an extra UInt32 to the front of the list of args, which ends up covering the single-byte Since |
Beta Was this translation helpful? Give feedback.
-
Hi @ronf,
I am testing one scenario where in I want to get rekey from server where server rekey threshold is 40MB. I am currently trying to send data on channel with help of proc.channel.send_packet method . Here I am sending 1kb data in for loop but on server side auth logs I get something like this.
channel 0: rcvd too much data 1024, win 512
Beta Was this translation helpful? Give feedback.
All reactions