# SwitchTower with public key authentication?

**URL:** <https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997>\
**Category:** Rails\
**Created:** [January 22, 2006, 6:07pm UTC](https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997 "2006-01-22T18:07:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/u/Pau_Garcia_i_Quiles)\
**Post date:** [January 22, 2006, 6:07pm UTC](https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997/1 "2006-01-22T18:07:47Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hello,

BEWARE: this is not a Rails question, but a SwitchTower question. I am  
asking  
here because SwitchTower is usually employed with Rails.

I am developing what we may call a “distributed video player” in Ruby  
(this is  
NOT a Rails application). It works this way: I have several boxes that  
play  
videos and one server, where I store the contents I will later send to  
the  
playing boxes (videos are played from local files, not streamed).

When I want to play a video, I want to play it at once in every box, so  
I must  
send it to every playing box, wait for the files to transfer to every  
box,  
then send a “play” command to every box.

I’m thinking of using SwitchTower to automate that step. The problem is  
the  
password to transfer the files. I’ve read  
[Peak Obsession](http://manuals.rubyonrails.com/read/chapter/97) and it looks like I need  
to  
have the same password for all servers. I don’t like this approach very  
much,  
I think it’s not very secure.

So the question is: is it possible to use public key authentication in  
SwitchTower?

* * *

Pau Garcia i Quiles  
[http://www.elpauer.org](http://www.elpauer.org)  
(En general no puedo contestar antes de 10 días)  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFD07uH/DzYv9iGJzsRAhwyAKCb2tvH1glmddmOrHtLRqIXupYaRgCg0z81  
jGSX+KdPX5qYs+wGZCmNM3w=  
=kZRS  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/u/Pau_Garcia_i_Quiles)\
**Post date:** [January 22, 2006, 7:30pm UTC](https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997/2 "2006-01-22T19:30:18Z")

</div>

Hi Pau,

You can use ssh-agent and ssh-add to make your public keys available  
for every ssh connection. If you do that and then run Switchtower, you  
don’t have to enter any passwords. It’ll use the keys it gets from the  
ssh-agent.

I used this page to set up my ssh-agent:  
[http://mah.everybody.org/docs/ssh](http://mah.everybody.org/docs/ssh)

Hope that helps,

Gijs van Tulder

---

<div class="post-metadata">

**Author:** ![Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/u/Pau_Garcia_i_Quiles)\
**Post date:** [January 22, 2006, 8:34pm UTC](https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997/3 "2006-01-22T20:34:31Z")

</div>

> I have ssh-agent working fine. Only when I try to connect to my own  
> host, then it asks for a password. Any ideas on how to make it work  
> from a host to the same host?

Stupid question perhaps, but have you added the public key of your own  
host to the list of authorized keys of that host (just like you’ve  
done for the remote hosts)?

Gijs

---

<div class="post-metadata">

**Author:** ![Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/u/Pau_Garcia_i_Quiles)\
**Post date:** [January 22, 2006, 8:22pm UTC](https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997/4 "2006-01-22T20:22:21Z")

</div>

I have ssh-agent working fine. Only when I try to connect to my own  
host, then it asks for a password. Any ideas on how to make it work  
from a host to the same host?

– G.

---

<div class="post-metadata">

**Author:** ![Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/u/Pau_Garcia_i_Quiles)\
**Post date:** [January 22, 2006, 9:23pm UTC](https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997/5 "2006-01-22T21:23:21Z")

</div>

On Jan 22, 2006, at 7:31 PM, Gijs van Tulder wrote:

> > I have ssh-agent working fine. Only when I try to connect to my own  
> > host, then it asks for a password. Any ideas on how to make it work  
> > from a host to the same host?
> 
> Stupid question perhaps, but have you added the public key of your own  
> host to the list of authorized keys of that host (just like you’ve  
> done for the remote hosts)?
> 
> Gijs

Not a stupid question at all. Have done that, tried the RSA key and  
DSA key too. For various IP and name combinations too. Somehow, I  
think it should be something I need to add to something in /etc/  
ssh … but I can’t figure out exactly what.

– G.

---

<div class="post-metadata">

**Author:** ![Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/u/Pau_Garcia_i_Quiles)\
**Post date:** [January 22, 2006, 11:16pm UTC](https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997/6 "2006-01-22T23:16:09Z")

</div>

On Jan 22, 2006, at 8:51 PM, Gijs van Tulder wrote:

> - In /etc/ssh/sshd\_config, is PubkeyAuthentication set to yes?
> - Also in /etc/ssh/sshd\_config, check if the name of the  
> authorized\_keys file is correct. (On some systems it’s called  
> authorized\_keys2.)
> - Check the permissions of your ~/.ssh/ directory and the  
> authorized\_keys file: chmod 755 and 644 respectively.

All those appear to be in order. I double checked everything and was  
on the verge on sending it to say that was the case, then I decided  
to hunt a little more. I have a ssh agent that wasn’t reading its  
socket anymore. Started the app up again and it read its socket ok  
(accepted ssh-add ~/.ssh/id\_dsa.pub) but no joy.

Ultimately, it appears that what you thought to be a stupid question  
was in fact the problem! Between mail and terminal, my brain forgot  
each time to do AUTHORIZED\_KEYS, and tab completed its way to  
KNOWN\_HOSTS. Blah! Sorry for wasting your time (and mine!) … 🙂  
Methinks an empty one should be created by default …

– G.

---

<div class="post-metadata">

**Author:** ![Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@Pau\_Garcia\_i\_Quiles](https://www.ruby-forum.com/u/Pau_Garcia_i_Quiles)\
**Post date:** [January 22, 2006, 9:53pm UTC](https://www.ruby-forum.com/t/switchtower-with-public-key-authentication/63997/7 "2006-01-22T21:53:59Z")

</div>

> Somehow, I think it should be something I need to add to  
> something in /etc/ ssh … but I can’t figure out exactly what.

- In /etc/ssh/sshd\_config, is PubkeyAuthentication set to yes?
- Also in /etc/ssh/sshd\_config, check if the name of the  
authorized\_keys file is correct. (On some systems it’s called  
authorized\_keys2.)
- Check the permissions of your ~/.ssh/ directory and the  
authorized\_keys file: chmod 755 and 644 respectively.

Gijs
