Forum: Ruby Using Net SSH to issue command on remote windows XP

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
47457e9a4eb054d2eac4e13221a38b28?d=identicon&s=25 Saritha Yeddula (saritha)
on 2008-10-14 08:04
Hi,

I want to issue window's DOS commands like "dir, cp, del..."
on a remote Windows XP machine.
I have installed OPENSSH on the remote windows machine
and trying to use the Net SSH.
I cannot get any of the DOS commands to work on the remote machine.

Any help ????

Thanks
Saritha
1b507a552850441a516948d488962d2e?d=identicon&s=25 Sniper Abandon (mokkai)
on 2008-10-14 08:56
Saritha Yeddula wrote:
> Hi,
>
> I want to issue window's DOS commands like "dir, cp, del..."
> on a remote Windows XP machine.
> I have installed OPENSSH on the remote windows machine
> and trying to use the Net SSH.
> I cannot get any of the DOS commands to work on the remote machine.
>
> Any help ????
>
> Thanks
> Saritha

what is your source(current) machine is it linux or windows ?
47457e9a4eb054d2eac4e13221a38b28?d=identicon&s=25 Saritha Yeddula (saritha)
on 2008-10-14 09:39
Pokkai Dokkai wrote:
> Saritha Yeddula wrote:
>> Hi,
>>
>> I want to issue window's DOS commands like "dir, cp, del..."
>> on a remote Windows XP machine.
>> I have installed OPENSSH on the remote windows machine
>> and trying to use the Net SSH.
>> I cannot get any of the DOS commands to work on the remote machine.
>>
>> Any help ????
>>
>> Thanks
>> Saritha
>
> what is your source(current) machine is it linux or windows ?

My source/Current machine is Windows
666b4e17b4bb0e2d999037a25f65a7cb?d=identicon&s=25 Heesob Park (phasis)
on 2008-10-14 11:51
(Received via mailing list)
Hi,

2008/10/14 Saritha Yeddula <syeddula@codegreennetworks.com>:
> Thanks
> Saritha

Try psexec.exe ( download at http://live.sysinternals.com/psexec.exe )

You can do remote command like this:

psexec \\192.168.0.1 -u administrator -p password cmd.exe /c dir

Regards,

Park Heesob
47457e9a4eb054d2eac4e13221a38b28?d=identicon&s=25 Saritha Yeddula (saritha)
on 2008-10-14 17:33
Heesob Park wrote:
> Hi,
>
> 2008/10/14 Saritha Yeddula <syeddula@codegreennetworks.com>:
>> Thanks
>> Saritha
>
> Try psexec.exe ( download at http://live.sysinternals.com/psexec.exe )
>
> You can do remote command like this:
>
> psexec \\192.168.0.1 -u administrator -p password cmd.exe /c dir
>
> Regards,
>
> Park Heesob

Thanks Park !

Can Net SSH be used if OPENSSH is installed for windows ?
since I'm using ruby Net SSH for issuing commands on remote linux
machines.
Is there any utility in ruby to issue command on remote windows machine.

Thanks
saritha
666b4e17b4bb0e2d999037a25f65a7cb?d=identicon&s=25 Heesob Park (phasis)
on 2008-10-15 04:20
(Received via mailing list)
2008/10/15 Saritha Yeddula <syeddula@codegreennetworks.com>:
>>
> machines.
> Is there any utility in ruby to issue command on remote windows machine.
>
What's your problem with Net SSH?

1. Install OpenSSH server

2. Create an user account for SSH

3. In OpenSSH bin folder
mkpasswd -l user >> ../etc/passwd

4. Run following code.

require 'net/ssh'
host = '127.0.0.1'
user = 'test'
password = 'test'
command = 'cmd.exe /c dir'
 Net::SSH.start( host, user, :password=> password) do |ssh|
    puts "Opened Connection to #{host}"
    puts ssh.exec!( "#{command}")
    puts "Closed Connection to #{host}"
  end

Regards,

Park Heesob
703fbc991fd63e0e1db54dca9ea31b53?d=identicon&s=25 Robert Dober (Guest)
on 2008-10-15 12:11
(Received via mailing list)
On Tue, Oct 14, 2008 at 5:33 PM, Saritha Yeddula
<syeddula@codegreennetworks.com> wrote:

Sure can
the only question is what shell you will use than! SSH is only the
transport layer, the application layer still is a different story.
I guess this is often forgotten when using it between 2 Linux boxes as
the application layers are so obviously compatible...

However if you installed openSSH with cygwin your shell should be bash
would this do? IIRC there is nothing DOS can do what bash cannot.

HTH
Robert

--
C'est véritablement utile puisque c'est joli.

Antoine de Saint Exupéry
47457e9a4eb054d2eac4e13221a38b28?d=identicon&s=25 Saritha Yeddula (saritha)
on 2008-10-15 22:59
Robert Dober wrote:
> On Tue, Oct 14, 2008 at 5:33 PM, Saritha Yeddula
> <syeddula@codegreennetworks.com> wrote:
>
> Sure can
> the only question is what shell you will use than! SSH is only the
> transport layer, the application layer still is a different story.
> I guess this is often forgotten when using it between 2 Linux boxes as
> the application layers are so obviously compatible...
>
> However if you installed openSSH with cygwin your shell should be bash
> would this do? IIRC there is nothing DOS can do what bash cannot.
>
> HTH
> Robert
>
> --
> C'est v�ritablement utile puisque c'est joli.
>
> Antoine de Saint Exup�ry

I have done as quoted by Park.
My ssh.exec! is not recognized.
Here is the error I get.

Opened Connection to
10.10.12.21c:/ruby/lib/ruby/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh/session.rb:199:in
`method_missing'
: undefined method `exec!' for #<Net::SSH::Session:0x34ad4d8>
(NoMethodError)
666b4e17b4bb0e2d999037a25f65a7cb?d=identicon&s=25 Heesob Park (phasis)
on 2008-10-16 03:12
(Received via mailing list)
2008/10/16 Saritha Yeddula <syeddula@codegreennetworks.com>:
>> However if you installed openSSH with cygwin your shell should be bash
> I have done as quoted by Park.
> My ssh.exec! is not recognized.
> Here is the error I get.
>
> Opened Connection to
> 10.10.12.21c:/ruby/lib/ruby/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh/session.rb:199:in
> `method_missing'
> : undefined method `exec!' for #<Net::SSH::Session:0x34ad4d8>
> (NoMethodError)
>
I tested with net-ssh-2.0.4
BTW, gem install net-ssh
failed with Zlib::BufError
So I installed it by downloading zip file.

Regards,

Park Heesob
This topic is locked and can not be replied to.