Tag: Scripting

OpenSolaris VNC server configuration

by Greg on Nov.14, 2009, under OpenSolaris

This is one of several, little, quick notes about OSOL config. I have done several installs now, and each time I forget some of the little things.  That’s what a Blog is for though, right?  There are lots of sites describing this online, so it’s not tough to find.  I just wanted to find it easier on my own site.

I am using OSOL 2009.06 in this, might change a bit on other versions.

1. Install the service/pkg if it is not already. I think it is though. I think I just had to enable it on 2009.06.

2. Edit the service.  There’s probably an easier way, but this is an example of how I learned one way and stuck to it.  And in OSOL, like Linux, there’s probably twenty different ways to do something.

svccfg -s xvnc-inetd

editprop

There are two lines I like to change. 1. is to add the WAIT for persistent connections.  2. Geometry, so I have a larger vnc window.  All I do is uncomment and add geometry and replace false with true.

setprop inetd_start/exec = astring: /usr/X11/bin/Xvnc -geometry 1280x800 -inetd -query localhost -once securitytypes=none

    

setprop inetd/wait = boolean: true

 

 
3. Edit /etc/X11/gdm/custom.conf  – add these lines.

[security]

DisallowTCP=false

AllowRoot=true

AllowRemoteRoot=true

 

[xdmcp]

Enable=true

4. Last, restart the services.  First I do a “svcadm disable xvnc-inetd gdm”, which will kill your X session and take you to a prompt.  Then I login and do, “svcadm enable -s xvnc-inetd gdm”, which should start up the login window again.  You should be able to use a vnc client to access port 5900 on your server and login.
 
 
From this point, I use plink in a batch file with Ultra-VNC to automate an SSH login to my system securely. (Well, not uber-secure. I have my password saved in this file. There are better ways to handle that.)  I am curious to know if anyone else out there has better scripts for this.
 
Make sure you edit the properties for your system and you have Ultra-VNC installed. Here’s the batch file:
@echo off

rem IP of the server

set SVR=1.1.1.1

 

rem SSH port, update your sshd_config to match

set SSHPORT=222

set SSHUSER=username

set SSHPW=passwdnotshownhere

 

 

rem this is the port on your system, not the server

set LPORT=5992

set LIP=127.0.0.92

 

rem this is the port on the server, below should work by default

set RPORT=5900

set RIP=127.0.0.1

 

rem Path to Uvnc, maybe other vnc clients will work too

rem Just update the cmd below

set VNCPATH=C:\Program Files\UltraVNC

set VNCCMD=%VNCPATH%\vncviewer.exe

 

rem Have plink/pskill in your path or in the same dir as this script

start plink -ssh -P %SSHPORT% %SVR% -l %SSHUSER% -pw %SSHPW% -C -v -batch -L %LIP%:%LPORT%:%RIP%:%RPORT% -T -N 

CHOICE /N /T 7 /D Y > NUL

"%VNCCMD%" %LIP%::%LPORT%

CHOICE /N /T 2 /D Y > NUL

pskill plink.exe

In the above, I have plink and pskill in path, you may need to provide the full path if not.  Pskill is Sysinternals tool from Microsoft.  I set a custom LPORT and LIP for each server I connect to. This way I can have several at once.  But be warned, pskill will kill all plink connections. That means, it will close all your VNC connections if you even close one.  Probably a better script can be made to handle the individual connections.
 
Also note, there’s no way to accept the host key on your first plink connection. I use Putty to login once, which saves the host key.  Then plink will work using that cached key.
Leave a Comment :, more...

Force logoff at a particular time

by Greg on Apr.02, 2009, under Scripting, Windows Vista, Windows XP

Man, I haven’t posted in ages! Well, here’s something I want to remember for later. Force a computer to logoff at a particular time, but still allow logons later. Using Active Directory, I think, will force a logon schedule and dissallow users from logon if not within scheduled times.

On the computer you want to force logoff, open the C: drive and create a text file. Then rename it to, force-logoff.bat
Be sure you can view the extensions, or it will hide the .txt at the end and this wont work. (it can’t be force-logoff.bat.txt, which is what you’ll get if you have “hide extensions of known file types” selected)
Then right click, edit.
Put this in the file and save it.

PsShutdown.exe -o -f

After that, find PsShutdown.exe and copy/paste it into the C:\Windows dir on that system. Get it from here:
http://download.sysinternals.com/Files/PsTools.zip
You’ll have to unzip that and get the Psshutdown tool out of it.  I usually just put all the Pstools in the Windows directory anyway, it’s handy to have.
Then to test, just double click the force-logoff.bat file and it should log you out.  NOTE: The first time you run any of the PSTools, you’ll get a little EULA and you’ll need to agree to the terms.  Not big deal, then after that you won’t get a popup.

Last, make a schedule for it to run every day at your desired time.

Here’s the link to the Microsoft site regarding PsShutdown command line usage.

http://technet.microsoft.com/en-us/sysinternals/bb897541.aspx

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

1st Byte Solutions