Send a DOS command to another host

Hi there!
I need to send a DOS command, like ‘shutdown …’, to another host in the LAN.
From a host runnig DOS (Windows), I’d use:

netuse \\[ip address] /user:[username] [password]
shutdown -r -f -t 0 -m [ip address] 

How can I do the same thing from a host running Linux?

I was looking the ‘net’ command of Samba, but I can’t make it work.
Somebody can help me?

Thank you in advance.

Long time ago we used commands like *remsh *and *rlogin *for these sort of things. Nowadays these are (like telnet) seen as a great security risk. It seems that these, once havily used, commands are not even installed by default on openSUSE (correct IMHO).

We use *ssh *for connecting to another system in CLI.

Hi
Telnet command is still there, just not the service (can be installed
though).

@aecordoba I would imagine you would need to activate the telnet
service on the remote machine and use that instead. If you could
install a shh server that would be better.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.29-0.1-default
up 3 days 8:46, 2 users, load average: 0.76, 0.58, 0.38
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.18

On Tue, 2009-10-06 at 19:36 +0000, aecordoba wrote:
> Hi there!
> I need to send a DOS command, like ‘shutdown …’, to another host in
> the LAN.
> From a host runnig DOS (Windows), I’d use:
>
>
> Code:
> --------------------
> netuse \[ip address] /user:[username] [password]
> shutdown -r -f -t 0 -m [ip address]
> --------------------
>
>
> How can I do the same thing from a host running Linux?
>
> I was looking the ‘net’ command of Samba, but I can’t make it work.
> Somebody can help me?

Technically, you’d probably use a wmi command nowadays in
Windows… but for what you’re talking about, one way to
do an arbitrary command on the remote host is via ssh.

ssh root@remotehost reboot

(for example)

You can make that password-less using keys assuming the
private key for the user invoking is enabled on the calling side
and the public key is known on the remote side by the root user.

e.g.
ssh-keygen -b 1024 -t rsa

this generates a public/private set of keys

If you enable a passphrase, you’ll need to

type it in to enable the use of your private

key (it’ll feel like you’re doing a password,

but it all takes place on the local side).

ssh root@remote host “mkdir .ssh;chmod 700 .ssh;cat
>>.ssh/authorized_keys2” <.ssh/id_rsa.pub

that was a one liner… just fyi

Basically you need the contents of your id_rsa.pub

concatenated onto the end of root’s .ssh/authorized_keys2 file.

You may have to edit /etc/ssh/sshd_config on the remote side
to allow root to login without-password (man sshd_config look
for PermitRootLogin without-password or forced-commands-only).
Restart sshd after making any changes on the remote side…
e.g. rcsshd restart

HTH,
Chris

I will learn about ssh, but could I send a DOS command (like shutdown) to a Windows machine by mean ‘ssh’? (I can’t install anything in remote host, and telnet is unavailable.)
Thank you for your answers.

No, at least as long as there is no SSH-server installed and running on the windows box (which is available but not “standard stuff” for windows).

For the record (and I would be kicking myself, if I would not write this here).

NEVER use telnet for remote management, especially not for remote connections from the outside.

Telnet is completely insecure as everything will be sent unencrypted.

Thank you, for your time!

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

If you want a system to send commands to another system you’re trying to
use the wrong OS (windows) but you’re in the right forum to get to the
right OS (Linux).

Good luck.

aecordoba wrote:
> Akoellh;2048098 Wrote:
>> No, at least as long as there is no SSH-server installed and running on
>> the windows box (which is available but not “standard stuff” for
>> windows).
>>
>> For the record (and I would be kicking myself, if I would not write
>> this here).
>>
>> NEVER use telnet for remote management, especially not for remote
>> connections from the outside.
>>
>> Telnet is completely insecure as everything will be sent unencrypted.
>
>
> Thank you, for your time!
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJKy/h2AAoJEF+XTK08PnB5rDsP/RT9LpasP/2W+ndIxP3kE6oC
6K5NPr+sX3c6l2T9llbLptH7QjJ1DIcWntJh5gPaI6O/HTMAqWnQm8Z8ePVGTLgt
Tpnyc8tTaSTeRS2EH3Ik9cBVrTf8Nzsi/mUS9zxentL3Az+Q1FHfcOO+jQ83y30a
uqV+VQrp/retPLqrT29i57TqNJ1ipw/lXU76XyT5mqe4WwnSx5Q6SNcvAjqONbNr
drSIQivKX0ccW9tdb4DIfrT9RNCoBuDatEKr2YVCXQFuLWPyBXpIvbKOLs5l4exB
qrY1uO1HDEs+zZyQUOgVinKs2qU+QjHDl72YX2wB2bVbZRB8CkP/5DJD73v6MwLU
OSmVHTJhmX7PS94vH4C9VpE0hurYJDZ3CDaiGNbgB1ou+EgmvQxUILLbGTPpE8Ac
8kVLghHvqDek0VpHDBNiuYaZl179ymsYYCr1GKqZE/HruinA+2o24Id5qSyxZ8l1
3Fi4H/1llTfME/EtXty29a4JusigmOu6wnRmFg2pk1mcOYd0himR4oxj1FiC1cnE
h//o5P9Ixolo4XjCbBdw/RbOHpbcIqIZWnBfjj7iZUqvbEPdWjBf6kLpHg4DywV3
O2DbRiEmkmH4s44mVTZkxIXoC3tdfI9Zb5OnWlXHw28lj/5mYjKbB5nuSW0jBEuA
mm7RswQLrQQkA8Ov2+ag
=lc3g
-----END PGP SIGNATURE-----

sshwindows.sf.net: OpenSSH for Windows

aecordoba wrote:
> I will learn about ssh, but could I send a DOS command (like shutdown)
> to a Windows machine by mean ‘ssh’? (I can’t install anything in remote
> host, and telnet is unavailable.)
> Thank you for your answers.
>
>

You can do this using WMI (as mentioned earlier). You’ll need a domain
admin credential (or something that can do the operation you’re wanting
to do). You can get the eval version of Zenoss and just keep
the wmic (and there’s one other command too… slips my mind right now)
and delete the rest (unless you want to mess around with Zenoss).

Then you can do wmi Win32 calls to your windows boxes… including
things like shutdown/restart, etc (if you use an account with privs).

WMI is the big backdoor on Windows.

You can view files, etc… even if nothing is being shared out.

On Wed, 2009-10-07 at 04:49 +0000, cjcox wrote:
> aecordoba wrote:
> > I will learn about ssh, but could I send a DOS command (like shutdown)
> > to a Windows machine by mean ‘ssh’? (I can’t install anything in remote
> > host, and telnet is unavailable.)
> > Thank you for your answers.
> >
> >
>
> You can do this using WMI (as mentioned earlier). You’ll need a domain
> admin credential (or something that can do the operation you’re wanting
> to do). You can get the eval version of Zenoss and just keep
> the wmic (and there’s one other command too… slips my mind right now)
> and delete the rest (unless you want to mess around with Zenoss).
>
> Then you can do wmi Win32 calls to your windows boxes… including
> things like shutdown/restart, etc (if you use an account with privs).
>
> WMI is the big backdoor on Windows.
>
> You can view files, etc… even if nothing is being shared out.
>

Example time (from work):

wmic -U ‘MYDOMAIN/cjcox%mypassword’ //cjc-xp "select * from

Win32_LocalTime"
CLASS: Win32_LocalTime
Day|DayOfWeek|Hour|Milliseconds|Minute|Month|Quarter|Second|WeekInMonth|
Year
6|2|23|0|56|10|4|0|2|2009

I may have spoke too soon about doing a remote command. You can
certainly look into doing a winexe command instead of wmic, but it
relies upon having a winexesvc running on the remote host. Now…
if can manage to compile winexesvc.exe yourself, there’s a place
you can install it where winexe will pick it up, copy it over
to the remote machine, execute it, run the command and then
stop the winexesvc on the remote machine.

Thank you for your answers.

Do you know ‘net’ command of samba?
Could this command be used for this purpose?

On Wed, 2009-10-07 at 15:26 +0000, aecordoba wrote:
> Thank you for your answers.
>
> Do you know ‘net’ command of samba?
> Could this command be used for this purpose?
>
>

Yes… you CAN do this… at least for doing something like
a shutdown.

net -I 192.168.1.2 -U cjcox rpc shutdown -r -t 1

Again, as long as the remote user you’re coming in as has
privs to do so.