SUMMARY
When retrieving a file from a Cisco SCP server, Cisco does not support SFTP on the server side, the channel is closed and interferes with the handling of the end of file check. This causes the following error to trickle up:
"msg": "Error transferring file from /tmp/tgyfdp81: Unexpected request: b'End of file while reading string'"
https://github.com/ansible/pylibssh/blob/27ce4def3505cccae41e113d1e7c55b3d71c2b9f/src/pylibsshext/scp.pyx#L164C18-L166
ISSUE TYPE
PYLISSH and LIBSSH VERSION
pylibssh at 27ce4de (level - at time of writing)
libssh at 63fbf00efef84f1591c3c82911c6a92e77ca8d2c (master - at time of writing) and 07d099f652224d66530fc603662a034d026e5d13 (prior to the quoting patch for Cisco SCP devices)
OS / ENVIRONMENT
Handy EE for testing this (adjust to checkout the right commits)
---
# ansible-navigator builder build --tag localhost/cisco-ios-libssh:stream8 --verbosity 3
additional_build_steps:
append_final:
- |-
RUN git clone https://git.libssh.org/projects/libssh.git /libssh \
&& git clone https://github.com/ansible/pylibssh.git /pylibssh
- |-
RUN mkdir /build \
&& cd /build \
&& cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug /libssh \
&& make \
&& echo "/build/lib" > /etc/ld.so.conf.d/libssh.conf \
&& ldconfig
- |-
RUN python3.11 -m pip install tox \
&& cd /pylibssh \
&& CFLAGS="-I/build/include -I/libssh/include" \
LDFLAGS="-L/build/lib" tox -e build-dists \
&& python3.11 -m pip install /pylibssh/dist/ansible_pylibssh*.whl
- RUN python3.11 -m pip install paramiko scp
- RUN echo "HostKeyAlgorithms +ssh-rsa" > /etc/ssh/ssh_config.d/99-ansible.conf
prepend_base:
- |-
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* \
&& sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
- RUN dnf install --assumeyes git
dependencies:
ansible_core:
package_pip: ansible-core<2.17
ansible_runner:
package_pip: ansible-runner<2.5
galaxy: |-
---
collections:
- name: ansible.netcommon
source: git+https://github.com/timway/ansible.netcommon.git
type: git
version: cisco-ios-libssh
- name: cisco.ios
version: 11.1.1
- name: community.network
version: 5.1.0
- name: community.routeros
version: 3.13.0
python_interpreter:
package_system: python3.11
system:
- cmake
- diffutils
- gcc
- gcc-c++
- git
- glibc-all-langpacks
- make
- nano
- ncurses
- openssh-clients
- openssl-devel
- patch
- python3.11-devel
- python3.11-pip
- python3.11-setuptools
- python3.11-wheel
- vim
- zlib-devel
images:
base_image:
name: quay.io/centos/centos:stream8
version: 3
STEPS TO REPRODUCE
- Create a small temporary file to copy to the switch with
dd if=/dev/random of=scratch.1 bs=512K count=3
- Run the playbook below against a Cisco IOS-XE device
---
- name: Copy a file to a switch
hosts: all
tasks:
- name: Copy the scratch.1 file to the switch
ansible.netcommon.net_put:
dest: flash:scratch.1
src: scratch.1
vars:
ansible_network_cli_ssh_type: libssh
EXPECTED RESULTS
The file is copied without issue.
ACTUAL RESULTS
[2025/11/12 02:45:35.017584, 3] ssh_scp_pull_request: Received SCP request: 'C0644 2004 scratch.1'
[2025/11/12 02:45:35.017611, 3] ssh_packet_need_rekey: rekey: [data_rekey_needed=0, out_blocks=10, in_blocks=20]
[2025/11/12 02:45:35.017659, 3] ssh_socket_unbuffered_write: Enabling POLLOUT for socket
[2025/11/12 02:45:35.017705, 3] packet_send2: packet: wrote [type=94, len=16, padding_size=5, comp=10, payload=10]
[2025/11/12 02:45:35.017727, 3] channel_write_common: ssh_channel_write wrote 1 bytes
[2025/11/12 02:45:35.017825, 3] ssh_channel_read_timeout: Read (2004) buffered : 0 bytes. Window: 2097122
[2025/11/12 02:45:35.054729, 3] ssh_packet_socket_callback: packet: read type 94 [len=2032,padding=17,comp=2014,payload=2014]
[2025/11/12 02:45:35.054760, 3] ssh_packet_process: Dispatching handler for packet type 94
[2025/11/12 02:45:35.054779, 3] channel_rcv_data: Channel receiving 2005 bytes data (local win=2097122 remote win=131070) on channel 43:3
[2025/11/12 02:45:35.054795, 3] channel_default_bufferize: placing 2005 bytes into channel buffer (stdout)
[2025/11/12 02:45:35.054806, 3] channel_rcv_data: Channel windows are now (local win=2095117 remote win=131070)
[2025/11/12 02:45:35.054817, 3] ssh_packet_need_rekey: rekey: [data_rekey_needed=0, out_blocks=10, in_blocks=145]
[2025/11/12 02:45:35.054823, 3] grow_window: growing window (channel 43:3) to 2097152 bytes : not needed (2095117 bytes)
[2025/11/12 02:45:35.054831, 3] ssh_packet_need_rekey: rekey: [data_rekey_needed=0, out_blocks=10, in_blocks=145]
[2025/11/12 02:45:35.054892, 3] ssh_socket_unbuffered_write: Enabling POLLOUT for socket
[2025/11/12 02:45:35.054911, 3] packet_send2: packet: wrote [type=94, len=16, padding_size=5, comp=10, payload=10]
[2025/11/12 02:45:35.054923, 3] channel_write_common: ssh_channel_write wrote 1 bytes
[2025/11/12 02:45:35.054937, 3] ssh_channel_read_timeout: Read (1) buffered : 1 bytes. Window: 2095117
[2025/11/12 02:45:35.054947, 3] grow_window: growing window (channel 43:3) to 2097152 bytes : not needed (2095117 bytes)
[2025/11/12 02:45:35.055119, 3] ssh_channel_read_timeout: Read (1) buffered : 0 bytes. Window: 2095117
[2025/11/12 02:45:35.191507, 3] ssh_packet_socket_callback: packet: read type 98 [len=32,padding=6,comp=25,payload=25]
[2025/11/12 02:45:35.191539, 3] ssh_packet_process: Dispatching handler for packet type 98
[2025/11/12 02:45:35.191551, 3] channel_rcv_request: received exit-status 0 on channel 43:3
[2025/11/12 02:45:35.191566, 3] ssh_packet_need_rekey: rekey: [data_rekey_needed=0, out_blocks=10, in_blocks=146]
[2025/11/12 02:45:35.191596, 3] ssh_packet_socket_callback: packet: read type 96 [len=16,padding=10,comp=5,payload=5]
[2025/11/12 02:45:35.191608, 3] ssh_packet_process: Dispatching handler for packet type 96
[2025/11/12 02:45:35.191615, 3] channel_rcv_eof: Received eof on channel (43:3)
[2025/11/12 02:45:35.191625, 3] ssh_packet_need_rekey: rekey: [data_rekey_needed=0, out_blocks=10, in_blocks=146]
[2025/11/12 02:45:35.191669, 3] ssh_packet_need_rekey: rekey: [data_rekey_needed=0, out_blocks=10, in_blocks=146]
[2025/11/12 02:45:35.191724, 3] ssh_socket_unbuffered_write: Enabling POLLOUT for socket
[2025/11/12 02:45:35.191738, 3] packet_send2: packet: wrote [type=96, len=16, padding_size=10, comp=5, payload=5]
[2025/11/12 02:45:35.191751, 3] ssh_channel_send_eof: Sent a EOF on client channel (43:3)
[2025/11/12 02:45:35.191759, 3] ssh_channel_read_timeout: Read (128) buffered : 0 bytes. Window: 2095117
[2025/11/12 02:45:35.191766, 3] ssh_packet_need_rekey: rekey: [data_rekey_needed=0, out_blocks=10, in_blocks=146]
[2025/11/12 02:45:35.191779, 3] packet_send2: packet: wrote [type=97, len=16, padding_size=10, comp=5, payload=5]
[2025/11/12 02:45:35.191789, 3] ssh_channel_close: Sent a close on client channel (43:3)
[2025/11/12 02:45:35.191810, 3] ssh_packet_socket_callback: packet: read type 97 [len=16,padding=10,comp=5,payload=5]
[2025/11/12 02:45:35.191821, 3] ssh_packet_process: Dispatching handler for packet type 97
[2025/11/12 02:45:35.191827, 3] channel_rcv_close: Received close on channel (43:3)
"msg": "Error transferring file from /tmp/tgyfdp81: Unexpected request: b'End of file while reading string'"
SUMMARY
When retrieving a file from a Cisco SCP server, Cisco does not support SFTP on the server side, the channel is closed and interferes with the handling of the end of file check. This causes the following error to trickle up:
https://github.com/ansible/pylibssh/blob/27ce4def3505cccae41e113d1e7c55b3d71c2b9f/src/pylibsshext/scp.pyx#L164C18-L166
ISSUE TYPE
PYLISSH and LIBSSH VERSION
pylibssh at 27ce4de (level - at time of writing)
libssh at 63fbf00efef84f1591c3c82911c6a92e77ca8d2c (master - at time of writing) and 07d099f652224d66530fc603662a034d026e5d13 (prior to the quoting patch for Cisco SCP devices)
OS / ENVIRONMENT
STEPS TO REPRODUCE
dd if=/dev/random of=scratch.1 bs=512K count=3EXPECTED RESULTS
The file is copied without issue.
ACTUAL RESULTS