Controlling windows system from a Linux box.

Set up winexe.

wget "ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/GRNET:/synnefo/CentOS_CentOS-6/x86_64/winexe-1.00-9.1.x86_64.rpm"
yum install winexe-1.00-9.1.x86_64.rpm

 

Test the connection

<pre>telnet 10.0.0.123 139</pre>

Now we can try the system out

winexe -U "User 1" --password=secretpassword //10.0.0.123 'cmd /C "whoami"'

If you get :

ERROR: Failed to open connection - ERRDOS:ERRnomem

then it’s probably a Windows 7 box

run

 reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "LargeSystemCache" /t REG_DWORD /d 1 /f
 reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "Size" /t REG_DWORD /d 3 /f

on the windows box and restart.

Now try again

winexe -U "User 1" --password=secretpassword //10.0.0.123 'cmd /C "whoami"'

you should get something like :

Win7Sstem\User 1

njoy 😉

 

 

ref: http://alan.lamielle.net/2009/09/03/windows-7-nonpaged-pool-srv-error-2017

ref: http://www.decuslib.com/decus/vmslt99a/nt/tips.txt

 

Start Teamviewer from an ssh session remotely

So you remote deskptop rebooted and teamviewer did not run on startup as it does not do in Linux for some strange reason:

Connect with ssh ( putty)

Then run

DISPLAY=`localhost`:0 teamviewer&

Njoy 🙂 !

Tar a folder or entire system through ssh

We all had the problem of needing to backup a folder or an entire system from a machine before decommissioning or as a postfix backup solution only to find tarring aint gonna work cause you have very little space left. Also there are folders you want to avoid tarring since they contain logs or system virtual folders that you want to skip.

So you need to get a tar from a machine have very little space left and you need to pull all the files in a compressed fashion; the following command calls a backup as root through ssh using tar on the source machine and skips the folders you do not want :

ssh root@pollux "tar zcvf - --exclude=/proc/* --exclude=/dev/* --exclude=/sys/* --exclude=/var/logs/* /" > /root/backup/pollux.fullandfinal.$(date '+%Y-%m-%d-%k-%M').tar.gz

The result of the above command is a backup of the / compressed at source piped through console through ssh back to your local / backup repo machine in .tar.gz format leaving out the rubbish thanks to the :

- --exclude=/proc/* --exclude=/dev/* --exclude=/sys/* --exclude=/var/logs/*

section. Note the “– —” the first – indicates extended parameters and –except leaves out any match to the path.

There you go one command to back them all.

(this could be easily bash-ed and cron-ed to produce a decent makeshift backup tool.

To check out the contents of the tar file you can use

tar -tvzf <archive.tar.gz>

This will show you the contents and leave a fail exit code in a bash script.