# Command Line Examples: ssh-add ~/.ssh/id\_rsa.pub ?

**URL:** <https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199>\
**Category:** Ansible Project\
**Created:** [January 12, 2013, 9:40am UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199 "2013-01-12T09:40:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rhea](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Rhea](https://forum.ansible.com/u/Rhea)\
**Post date:** [January 12, 2013, 9:40am UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199/1 "2013-01-12T09:40:31Z")

</div>

All,

[http://ansible.cc/docs/examples.html](http://ansible.cc/docs/examples.html), says **“$ ssh-add ~/.ssh/id\_rsa.pub”**

Is that typo or am I missing something?

===man ssh-add===  
ssh-add — adds private key identities to the authentication agent

Thanks,  
Rhea

---

<div class="post-metadata">

**Author:** ![Jim\_Richardson](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@Jim\_Richardson](https://forum.ansible.com/u/Jim_Richardson)\
**Post date:** [January 12, 2013, 9:59am UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199/2 "2013-01-12T09:59:15Z")

</div>

generally, for id\_\<crypto\>.pub it's  
ssh-add

---

<div class="post-metadata">

**Author:** ![Rhea](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Rhea](https://forum.ansible.com/u/Rhea)\
**Post date:** [January 12, 2013, 10:32am UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199/3 "2013-01-12T10:32:22Z")

</div>

Sorry, I did not understand what you meant but I’m assuming that it’s correct and not a typo. But the command does not work for me with the .pub file but works well with the private key. Why do I need to add public key also, my public key will be with other nodes and I need the private key to authenticate right?

[root@controller .ssh]# ssh-add **id\_rsa.pub**  
Enter passphrase for id\_rsa.pub:  
Bad passphrase, try again for id\_rsa.pub:  
Bad passphrase, try again for id\_rsa.pub:

[root@controller .ssh]# ssh-add id\_rsa  
Enter passphrase for id\_rsa:  
Identity added: id\_rsa (id\_rsa)  
[root@controller .ssh]#

-Rhea

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [January 12, 2013, 10:37am UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199/4 "2013-01-12T10:37:14Z")

</div>

> Why do I need to add public key  
> also, my public key will be with other nodes and I need the private key to  
> authenticate right?

You don't add the public key, which is on the nodes, just the private  
key which is used for authenticating against the public key on the  
nodes. You are correct. 🙂

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

---

<div class="post-metadata">

**Author:** ![Rhea](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Rhea](https://forum.ansible.com/u/Rhea)\
**Post date:** [January 12, 2013, 10:47am UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199/5 "2013-01-12T10:47:26Z")

</div>

Thank you. Is the instruction on [http://ansible.cc/docs/examples.html](http://ansible.cc/docs/examples.html) incorrect? I can safely replace the step **$ ssh-add ~/.ssh/id\_rsa.pub with $ ssh-add ~/.ssh/id\_rsa ?**

-Rhea

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [January 12, 2013, 2:18pm UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199/6 "2013-01-12T14:18:21Z")

</div>

Yes, it's a definite typo.

Patches to the documentation can be made by editing the  
docsite/rst/\*.rst files in the checkout, and then submitting a github  
pull request.

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [January 12, 2013, 2:52pm UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199/7 "2013-01-12T14:52:42Z")

</div>

> Is the instruction on [http://ansible.cc/docs/examples.html](http://ansible.cc/docs/examples.html) incorrect?  
> I can safely replace the step \*$ ssh-add ~/.ssh/id\_rsa.pub with $ ssh-add  
> ~/.ssh/id\_rsa ?\*

You add your private keys, irrespective of what their filenames are. In  
other words, if you created your key in a file called  
"id\_rhea\_ansible.gizmo", you would then `ssh-add ~/.ssh/id\_rhea\*.gizmo'. 🙂

And yes, the example is basically incorrect. I'll submit a doc patch in  
a moment (but it will be some time before that shows up on the Web site).

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

---

<div class="post-metadata">

**Author:** ![Rhea](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Rhea](https://forum.ansible.com/u/Rhea)\
**Post date:** [January 13, 2013, 4:31am UTC](https://forum.ansible.com/t/command-line-examples-ssh-add-ssh-id-rsa-pub/12199/8 "2013-01-13T04:31:24Z")

</div>

Cool 🙂 Thank you very much.

Since I’m still beginning with all of this, the example confused me 🙂

Thanks again!
