Open iamgini opened 2 years ago
I have installed and switched to paramkio
as follows and its working
[persistent_connection]
#ssh_type = libssh
ssh_type = auto
Any idea why libssh
is not able to handle this ?
@ganeshrn My apologies for tagging you here.
I was referring to your article New LibSSH Connection Plugin for Ansible Network Replaces Paramiko, Adds FIPS Mode Enablement and noticed this is not really working in my case.
Do we have any other references or guidance on this ?
Thank in advance
I think you need to try add in /etc/ssh/ssh_config this:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512
and run: ssh-keygen -A
I had done something like this in the past on my Ansible control node for support of older IOS devices
- name: add 'KexAlgorithms +diffie-hellman-group1-sha1' to /etc/ssh/ssh_config (for Cisco ssh support)
blockinfile:
path: /etc/ssh/ssh_config
marker: "# >> {mark} ANSIBLE MANAGED BLOCK - Older Cisco IOS support SHA-1"
insertafter: 'Host \*'
block: |
{{ item }}
with_items:
- ' KexAlgorithms +diffie-hellman-group1-sha1'
@epicanthal and @sprootik
Thank you for that. Yes, but with libssh
it didn't work.
I am having the same issue with libssh
not taking the cipher options. It also doesn't seem to be allowing paramiko to be used with the ios module.
Is there any work around to this?
I think the best solution would be to fully support ansible_ssh_common_args
. Currently, it can be used to define a proxy, but no other options. It is unclear to me why that restriction exists.
I met the same issue for force10 networks, is there any progress?
I've tried to add var: ansible_libssh_config_file
, but it doesn't work. Seems that another pr: https://github.com/ansible/pylibssh/pull/479 haven't been merged.
Nothing as of now. Waiting! :(
using + to append algorithms/ciphers in ssh config files doesn't work either, related or should I open a separate issue for it?
Ran into this same issue recently, after some testing I learned that if using libssh with network_cli it will read in configuration from your ~/.ssh/config file. Config in ansible.cfg doesn't seem to be respected in this case. Testing done with ansible.netcommon v6.0.0 on rhel8
For my situation, we were working with some old Cisco boxes and only needed the following in ssh config to make the connection:
Host cisco_boxs
KexAlgorithms +diffie-hellman-group1-sha1
@epicanthal solution above shows how you can do this programmatically if needed: https://github.com/ansible-collections/ansible.netcommon/issues/430#issuecomment-1172721717
@jakestec can you verify this is still working? Running on recent macOS, my ssh_config
doesn't seem to be honored.
ansible [core 2.17.6]
config file = [private]
configured module search path = ['/Users/alexander/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/10.6.0/libexec/lib/python3.12/site-packages/ansible
ansible collection location = [private]
executable location = /opt/homebrew/bin/ansible
python version = 3.12.7 (main, Oct 1 2024, 02:05:46) [Clang 16.0.0 (clang-1600.0.26.3)] (/opt/homebrew/Cellar/ansible/10.6.0/libexec/bin/python)
jinja version = 3.1.4
libyaml = True
Host myswitch
Ciphers aes256-ctr,aes256-cbc
ControlMaster no
HostKeyAlgorithms +ssh-rsa
KexAlgorithms +diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
Port 22
PubkeyAcceptedKeyTypes +ssh-rsa
fatal: [MySwitch]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"commands": [
"show version"
],
"interval": 1,
"match": "all",
"retries": 9,
"wait_for": null
}
},
"msg": "ssh connection failed: ssh connect failed: kex error : no match for method mac algo client->server: server [hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96], client [hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512]"
}
@alehaa Yup, the container executing our ansible code is connecting almost daily to devices using this configuration. Unfortunately I don't have access to any MacOS machines to test.
SUMMARY
we want to use
ansible.netcommon.network_cli
(which is the recommended method overparamiko
) but the old devices are only having old ciphers and unable to use it withansible.netcommon.network_cli
ISSUE TYPE
COMPONENT NAME
ansible.netcommon.network_cli
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Target Device: Cisco ASA (v9.8)
STEPS TO REPRODUCE
ansible.cfg
inventory
EXPECTED RESULTS
Ansible is able to connect to the device and execute the commands.
ACTUAL RESULTS