Open zcy382725 opened 1 year ago
it seems that send_command() result also start with a "\n" in output in ubuntu2204
it seems that send_command() result also start with a "\n" in output in ubuntu2204
Same for me on 22.04
I don't have enough hosts & distros to test on but stripping the raw output of md5sum fixed it for me.
dest_md5 = self.process_md5(dest_md5.strip()).strip()
log:
{'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} Traceback (most recent call last): File "/builds/infra/sw_dump/dump.py", line 35, in
output = file_transfer(net_connect,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/netmiko/scp_functions.py", line 122, in file_transfer
with TransferClass(*scp_args) as scp_transfer:
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/netmiko/ssh_dispatcher.py", line 503, in FileTransfer
return FileTransferClass(args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/netmiko/linux/linux_ssh.py", line 179, in init
super().init(
File "/usr/local/lib/python3.11/site-packages/netmiko/scp_handler.py", line 112, in init
self.remote_md5(remote_file=source_file) if hash_supported else None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/netmiko/linux/linux_ssh.py", line 214, in remote_md5
dest_md5 = self.process_md5(dest_md5).strip()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/netmiko/linux/linux_ssh.py", line 219, in process_md5
return super(LinuxFileTransfer, LinuxFileTransfer).process_md5(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/netmiko/scp_handler.py", line 359, in process_md5
raise ValueError(f"Invalid output from MD5 command: {md5_output}")
ValueError: Invalid output from MD5 command:
4977085b132f104643c75695b8ba1af2 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf
i've checked the scp_handler.py file and modified process_md5() def :
it seems some md5_output has a '\n' in begining(ubuntu22.04)
{'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400056.unf autobackup_7.2.94_20230514_2000_1684094400056.unf ['2674b3d0e1353125e6a0298024dddc37 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400056.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400016.unf autobackup_7.2.94_20230514_2000_1684094400016.unf ['1b738b8a69ab968caecbdad112f92058 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400016.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf autobackup_7.2.94_20230514_2000_1684094400030.unf ['122132d4a4b1b1f1f4ae727e7aea4ff0 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'}
/root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf autobackup_7.2.94_20230514_2000_1684094400030.unf ['', '4977085b132f104643c75695b8ba1af2 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400026.unf autobackup_7.2.94_20230514_2000_1684094400026.unf ['58fd1ca3ba475da91584efeaac636d3e /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400026.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400020.unf autobackup_7.2.94_20230514_2000_1684094400020.unf ['269953a481129a39ec5488ea2f7cfa32 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400020.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400012.unf autobackup_7.2.94_20230514_2000_1684094400012.unf ['b54d1d571d60b700a8c8218fd886ee29 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400012.unf']