# Ssh Passwordless authentication for Cisco switch

**URL:** <https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242>\
**Category:** Get Help\
**Created:** [November 30, 2024, 9:07am UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242 "2024-11-30T09:07:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![SharanKumarThummala](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sharankumarthummala/32/5608_2.png) [@SharanKumarThummala](https://forum.ansible.com/u/SharanKumarThummala)\
**Post date:** [November 30, 2024, 9:07am UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/1 "2024-11-30T09:07:51Z")

</div>

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](mailto:ann@10.2.200.49): Permission denied (publickey).

please help me on this thank you

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [November 30, 2024, 12:25pm UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/2 "2024-11-30T12:25:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [November 30, 2024, 3:46pm UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/3 "2024-11-30T15:46:39Z")

</div>

> [@SharanKumarThummala](#):
>
> for single switch i am taking backup successfully.

How does Ansible connect to this single switch?

---

<div class="post-metadata">

**Author:** ![SharanKumarThummala](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sharankumarthummala/32/5608_2.png) [@SharanKumarThummala](https://forum.ansible.com/u/SharanKumarThummala)\
**Post date:** [December 1, 2024, 6:59am UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/4 "2024-12-01T06:59:55Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![SharanKumarThummala](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sharankumarthummala/32/5608_2.png) [@SharanKumarThummala](https://forum.ansible.com/u/SharanKumarThummala)\
**Post date:** [December 1, 2024, 7:02am UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/5 "2024-12-01T07:02:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [December 1, 2024, 1:01pm UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/6 "2024-12-01T13:01:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![SharanKumarThummala](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sharankumarthummala/32/5608_2.png) [@SharanKumarThummala](https://forum.ansible.com/u/SharanKumarThummala)\
**Post date:** [December 2, 2024, 4:39am UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/7 "2024-12-02T04:39:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [December 2, 2024, 9:54am UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/8 "2024-12-02T09:54:47Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![SharanKumarThummala](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sharankumarthummala/32/5608_2.png) [@SharanKumarThummala](https://forum.ansible.com/u/SharanKumarThummala)\
**Post date:** [December 5, 2024, 7:45am UTC](https://forum.ansible.com/t/ssh-passwordless-authentication-for-cisco-switch/11242/9 "2024-12-05T07:45:46Z")

</div>

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