Ssh Passwordless authentication for Cisco switch

I am using centos 9 server for ansible and i want to connect all switch to ansible.

for single switch i am taking backup successfully.

i create group for multiple switch and i am trying to connect with ssh public key.

ann@10.2.200.49: Permission denied (publickey).

please help me on this thank you

Can you connect using ssh ann@10.2.200.49 using a public key?

How does Ansible connect to this single switch?

hi chris,

i want to connect to the switch with out password using rsa.pub key i am trying it was showing permission denied (public key)

hi Todd Lewis,

thanks for reply,

i connected ssh using password.

now i want to connect my switch without password i create a ssh key and i copied in the switch.

after i removed the ssh password authentication on switch. i selected the ssh auto-login. getting the above error

Are there logs on the switch that indicate why public key authentication is not working?

Is the ~/.ssh directory 0700 and the ~/.ssh/authorized_keys file 0600 and are they both owned by the user you are connecting as?

You will need to get SSH connections working before you can use SSH for Ansible.

drwx------. 2 root root 94 Nov 30 17:55 .ssh
and this are .ssh file permission.
drwx------. 2 root root 94 Nov 30 17:55 .
dr-xr-x—. 8 root root 4096 Dec 2 10:02 …
-rw-r–r–. 1 root root 421 Nov 30 15:04 config
-rw-------. 1 root root 2610 Nov 29 17:37 id_rsa
-rw-r–r–. 1 root root 580 Nov 29 17:37 id_rsa.pub
-rw-r–r–. 1 root root 3482 Nov 30 17:58 known_hosts
-rw-r–r–. 1 root root 3482 Nov 30 09:57 known_hosts.old
SSH connections working before you can use SSH for Ansible?
before i am using ssh username and password it was working.

If you want to use SSH public key authentication then you need to set it up, copy your local ~/.ssh/id_rsa.pub file to ~/.ssh/authorized_keys on the switch and make it 0600.

2 Likes

i connect the switch with different server (centos 8 ) it was working fine. thanks for you support