"No Such File or Directory" on Cisco IOS XE router using net_put
- Dominant language
- Cython
- Stars
- 79
- Forks
- 47
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 6
Description
##### SUMMARY
Transferring a file to a cisco router results in `Initializing SCP session of remote file [bootflash:cat9k_iosxe.17.12.04.SPA.bin] for write failed with error [b'Socket error: No such file or directory'`
I looked through the source code, the failure occurs when pylibssh calls the libssh.ssh_scp_init method. But, I didn't go any further. (See line 64 here: https://github.com/ansible/pylibssh/blob/devel/src/pylibsshext/scp.pyx)
Context: https://stackoverflow.com/questions/76789209/no-such-file-or-directory-error-when-using-ansibles-net-put-and-libssh-to-a
## Workaround
This works fine if `ansible_network_cli_ssh_type: paramiko`
##### ISSUE TYPE
- Bug Report
##### PYLISSH and LIBSSH VERSION
```paste below
ansible-pylibssh 1.2.2
```
##### OS / ENVIRONMENT
```
ansible [core 2.17.6]
config file = /workspaces/topco.network_automation/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.12/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.12.7 (main, Oct 1 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] (/usr/bin/python3)
jinja version = 3.1.4
libyaml = True
```
##### STEPS TO REPRODUCE
```paste below
- name: Copy the candidate IOS image to the switch. This can take 5+ minutes for 1GB switch bundles.
when: ios_verify.parsed.present is false
vars:
ansible_command_timeout: 600
ansible.netcommon.net_put:
src: "{{ local_image_dir }}/{{ ios_image }}"
dest: "{{ flash_dir }}{{ ios_image }}"
protocol: scp
overwrite: true
```
##### EXPECTED RESULTS
File is copied
##### ACTUAL RESULTS
```paste below
Initializing SCP session of remote file [bootflash:cat9k_iosxe.17.12.04.SPA.bin] for write failed with error [b'Socket error: No such file or directory'
```
Contributor guide
Research direction
Start by reproducing the net_put SCP transfer with the Cisco IOS XE example and inspect src/pylibsshext/scp.pyx around line 64, where the issue reports pylibssh calling libssh.ssh_scp_init. Compare the failing SCP path with the working Paramiko workaround; done means the specified bootflash file is copied successfully without the socket error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ansible, python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100