# File attributes

**URL:** <https://www.ruby-forum.com/t/file-attributes/81219>\
**Category:** Ruby\
**Created:** [January 6, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/file-attributes/81219 "2007-01-06T19:30:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krekna\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a9adbd/32.png) [@Krekna\_M](https://www.ruby-forum.com/u/Krekna_M)\
**Post date:** [January 6, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/file-attributes/81219/1 "2007-01-06T19:30:19Z")

</div>

Lo!

Busy with my program, I run in to 2 questions.

In a certain method I want to open a ssh connection by a certain user.  
I need to sudo to an ssh user to make the passwordless connection via  
public-private key authorization. How can I do this in Ruby?  
FYI: I am not allowed to use sudo su - ssh -c [ssh command].

Thanks,  
Krekna

---

<div class="post-metadata">

**Author:** ![Krekna\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a9adbd/32.png) [@Krekna\_M](https://www.ruby-forum.com/u/Krekna_M)\
**Post date:** [January 19, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/file-attributes/81219/2 "2007-01-19T16:29:40Z")

</div>

On 1/5/07, Krekna M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Lo!
> 
> Busy with my program, I run in to 2 questions.
> 
> In a certain method I want to open a ssh connection by a certain user.  
> I need to sudo to an ssh user to make the passwordless connection via  
> public-private key authorization. How can I do this in Ruby?  
> FYI: I am not allowed to use sudo su - ssh -c [ssh command].

1. you can start programs by `command` or Kernel#system, or IO#popen
2. you probably want to call `sudo -u <username> ssh -c <command>`  
or even  
user = ‘joe’  
cmd = ‘ls’  
`sudo -u #{user} ssh -c #{cmd}`  
but then be careful what you are passing there.
