paramiko / paramiko/paramiko

EOF sent for already closed channel

Open
#1,584 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs investigation
Dominant language
Python
Stars
9.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

For some reason (probably related to #1115) paramiko sends EOF for an already closed Channel, causing the Transport to close the whole SSH session.

paramiko log

2019-12-26 23:10:06,019 f:channel.py   p:DEBUG > [chan 8129] Max packet in: 32768 bytes
2019-12-26 23:10:07,014 f:channel.py   p:DEBUG > [chan 8129] Max packet out: 32768 bytes
2019-12-26 23:10:08,050 f:channel.py   p:DEBUG > [chan 8129] Sesch channel 8129 request ok
2019-12-26 23:10:08,085 f:channel.py   p:DEBUG > [chan 8129] EOF received (8129)
2019-12-26 23:10:08,087 f:channel.py   p:DEBUG > [chan 8129] EOF sent (8129)
2019-12-26 23:10:08,692 f:transport.py p:INFO  > Disconnect (code 2): Received ieof for nonexistent channel 11.

SSHD log

Dec 26 23:10:06 ip-10-0-109-19 sshd[1936]: debug1: server_input_channel_open: ctype session rchan 8129 win 2097152 max 32768
Dec 26 23:10:06 ip-10-0-109-19 sshd[1936]: debug1: input_session_request
Dec 26 23:10:06 ip-10-0-109-19 sshd[1936]: debug1: channel 11: new [server-session]
Dec 26 23:10:06 ip-10-0-109-19 sshd[1936]: debug1: session_new: session 11
Dec 26 23:10:06 ip-10-0-109-19 sshd[1936]: debug1: session_open: channel 11
Dec 26 23:10:06 ip-10-0-109-19 sshd[1936]: debug1: session_open: session 11: link with channel 11
Dec 26 23:10:06 ip-10-0-109-19 sshd[1936]: debug1: server_input_channel_open: confirm session
Dec 26 23:10:07 ip-10-0-109-19 sshd[1936]: debug1: server_input_channel_req: channel 11 request exec reply 1
Dec 26 23:10:07 ip-10-0-109-19 sshd[1936]: debug1: session_by_channel: session 11 channel 11
Dec 26 23:10:07 ip-10-0-109-19 sshd[1936]: debug1: session_input_channel_req: session 11 req exec
Dec 26 23:10:07 ip-10-0-109-19 sshd[1936]: Starting session: command for centos from 10.0.226.244 port 51038 id 11
Dec 26 23:10:07 ip-10-0-109-19 sshd[1933]: debug1: session_new: session 11
Dec 26 23:10:07 ip-10-0-109-19 sshd[1936]: debug1: Received SIGCHLD.
Dec 26 23:10:07 ip-10-0-109-19 sshd[1936]: debug1: session_by_pid: pid 22847
Dec 26 23:10:07 ip-10-0-109-19 sshd[1936]: debug1: session_exit_message: session 11 channel 11 pid 22847
Dec 26 23:10:07 ip-10-0-109-19 sshd[1936]: debug1: session_exit_message: release channel 11
Dec 26 23:10:08 ip-10-0-109-19 sshd[1936]: debug1: session_by_channel: session 11 channel 11
Dec 26 23:10:08 ip-10-0-109-19 sshd[1936]: debug1: session_close_by_channel: channel 11 child 0
Dec 26 23:10:08 ip-10-0-109-19 sshd[1936]: Close session: user centos from 10.0.226.244 port 51038 id 11
Dec 26 23:10:08 ip-10-0-109-19 sshd[1936]: debug1: channel 11: free: server-session, nchannels 12
Dec 26 23:10:08 ip-10-0-109-19 sshd[1936]: channel_by_id: 11: bad id: channel free
Dec 26 23:10:08 ip-10-0-109-19 sshd[1936]: Disconnecting: Received ieof for nonexistent channel 11.
Dec 26 23:10:08 ip-10-0-109-19 sshd[1936]: debug1: do_cleanup
Dec 26 23:10:08 ip-10-0-109-19 sshd[1933]: debug1: do_cleanup
Dec 26 23:10:08 ip-10-0-109-19 sshd[1933]: debug1: PAM: cleanup
Dec 26 23:10:08 ip-10-0-109-19 sshd[1933]: debug1: PAM: closing session
Dec 26 23:10:08 ip-10-0-109-19 sshd[1933]: pam_unix(sshd:session): session closed for user centos
Dec 26 23:10:08 ip-10-0-109-19 sshd[1933]: debug1: PAM: deleting credentials
Dec 26 23:10:13 ip-10-0-109-19 sshd[1915]: debug1: Forked child 22859.
Dec 26 23:10:13 ip-10-0-109-19 sshd[22859]: debug1: Set /proc/self/oom_score_adj to 0
Dec 26 23:10:13 ip-10-0-109-19 sshd[22859]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
Dec 26 23:10:13 ip-10-0-109-19 sshd[22859]: debug1: inetd sockets after dupping: 3, 3
Dec 26 23:10:13 ip-10-0-109-19 sshd[22859]: Connection from 10.0.226.244 port 37794 on 10.0.109.19 port 22

When used in fabric this behavior causes fabric connection to stop waiting for other processes that are run via other channels and exit them with return code -1.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the channel lifecycle in channel.py and the related handling in transport.py, using the supplied Paramiko and sshd logs as the reproduction context. Identify why EOF is sent after the channel is closed, then verify that the affected SSH session remains usable for other channels and that the closed channel no longer triggers a disconnect.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.