New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paramiko cannot connect to tamte server #2161
Comments
That's an issue of tmate server settings. Please ask on https://groups.google.com/group/tmate-io. |
It seems your tmate server requires compression in ssh connection by the settings. I think the settings typically should be configured to accept both with/without |
It worked, now
|
Your script has something wrong. The transport in the |
Full script as requested: import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(username="**", hostname="sgp1.tmate.io", compress=True)
print("Connected Succesfully.")
ssh.exec_command("ls")
print("Finished executing first command")
ssh.exec_command("ls")
print("Finished executing second command") Execution results
The first execution returns stdin, stdout, stderr like this:
In stdout, I see: |
That is not a paramiko issue. I think it is unable to send any commands to tmate server. The ssh connection to tmate server is used only for terminal sharing. I have no idea about what you want to do with paramiko. Please ask on tmate forum. |
I guess that tmake server responds |
What I need to achieve with tmate is SSHing over internet, not just local network. I'm not using it for file transfer. Here is the logfile for the same script.
|
I'm receiving different error now, instead of cosed connection, I get EOF error: Connected Succesfully.
Finished executing first command
---------------------------------------------------------------------------
EOFError Traceback (most recent call last)
Cell In[23], line 13
10 ssh.exec_command("ls")
11 print("Finished executing first command")
---> 13 ssh.exec_command("ls")
14 print("Finished executing second command")
File ~\venvs\ve\lib\site-packages\paramiko\client.py:525, in SSHClient.exec_command(self, command, bufsize, timeout, get_pty, environment)
485 def exec_command(
486 self,
487 command,
(...)
491 environment=None,
492 ):
493 """
494 Execute a command on the SSH server. A new `.Channel` is opened and
495 the requested command is executed. The command's input and output
(...)
523 Added the ``get_pty`` kwarg.
524 """
--> 525 chan = self._transport.open_session(timeout=timeout)
526 if get_pty:
527 chan.get_pty()
File ~\venvs\ve\lib\site-packages\paramiko\transport.py:920, in Transport.open_session(self, window_size, max_packet_size, timeout)
892 def open_session(
893 self, window_size=None, max_packet_size=None, timeout=None
894 ):
895 """
896 Request a new channel to the server, of type ``"session"``. This is
897 just an alias for calling `open_channel` with an argument of
(...)
918 Added the ``window_size`` and ``max_packet_size`` arguments.
919 """
--> 920 return self.open_channel(
921 "session",
922 window_size=window_size,
923 max_packet_size=max_packet_size,
924 timeout=timeout,
925 )
File ~\venvs\ve\lib\site-packages\paramiko\transport.py:1051, in Transport.open_channel(self, kind, dest_addr, src_addr, window_size, max_packet_size, timeout)
1049 if e is None:
1050 e = SSHException("Unable to open channel.")
-> 1051 raise e
1052 if event.is_set():
1053 break
File ~\venvs\ve\lib\site-packages\paramiko\transport.py:2110, in Transport.run(self)
2108 self._send_kex_init()
2109 try:
-> 2110 ptype, m = self.packetizer.read_message()
2111 except NeedRekeyException:
2112 continue
File ~\venvs\ve\lib\site-packages\paramiko\packet.py:459, in Packetizer.read_message(self)
451 def read_message(self):
452 """
453 Only one thread should ever be in this function (no other locking is
454 done).
(...)
457 :raises: `.NeedRekeyException` -- if the transport should rekey
458 """
--> 459 header = self.read_all(self.__block_size_in, check_rekey=True)
460 if self.__etm_in:
461 packet_size = struct.unpack(">I", header[:4])[0]
File ~\venvs\ve\lib\site-packages\paramiko\packet.py:303, in Packetizer.read_all(self, n, check_rekey)
301 x = self.__socket.recv(n)
302 if len(x) == 0:
--> 303 raise EOFError()
304 out += x
305 n -= len(x)
EOFError: |
You must use Also, it is need to use
The following script is to view the shared session on tmate server: import paramiko, os
with paramiko.Transport('sgp1.tmate.io') as transport:
transport.use_compression()
transport.start_client()
transport.auth_none('---- your token here ----')
with transport.open_session() as sess:
sess.set_combine_stderr(True)
sess.get_pty()
sess.invoke_shell()
while sess.active:
while sess.recv_ready():
os.write(1, sess.recv(128)) |
You should describe what you want to do with paramiko. Otherwise, please close this issue and ask on tmate forum. |
Ah, it is unable to request |
Description of what I want to do:
I assumed that whatever is doable via Thanks for the snippet. I'm not sure if it can be streamlined in the future so that it is as simple as |
What is the status of this, @thisismygitrepo? Did you get this to work? If not, do you have any further information about what features/fixes you might need in paramiko to make it work?
If you still think this would be a helpful change, can you clarify what you mean by "this is handled internally if not passed"? Are you suggesting that |
@bskinn
|
@jun66j5 -- do you know if common SSH implementations will automatically try with and without compression? |
I'm adding the "Feature" tag to this because it looks to me like there may be additional implementation required in order to make |
Separately, @thisismygitrepo -- to make sure that searches for 'tmate' can find this ticket, could you fix the typo in the issue name ( |
The OpenSSH client sends kexinit packets to prefer the compression setting, however paramiko with
See also: |
I'm trying to ssh to Tmate, a popular terminal sharing server.
Via ssh, the process is easy:
ssh {user_name}/{sess_name}@sgp1.tmate.io
But Paramiko doesn't seem to be able to do that.
I get those types of errors:
Is this possible at all?
What is missing here?
The text was updated successfully, but these errors were encountered: