The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 02:14:22 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Installing a Windows Virtual Machine on Linux with Only SSH Access  (Read 5117 times)
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« on: May 31, 2008, 07:10:08 PM »

This one's a real rip-snorter, and it's going to take me a while to type. I was in need of a box on which to run some windows-only apps, but being the open source/LAMP fanboi I am, all my hosting is done on LAMP servers. What follows is the steps I took in order to get a virtual instance of Windows running on one of my Fedora Core 6 boxes. Once you're up and running, you can go nuts. Install an FTP server on the windows box like filezilla and forward incoming requests on some unused port on your dedicated box down to port 21 on the virtual machine, etc.

First off, you can do this all with the RPMs, or compile the apps from source, but I chose to use Yum.

You're going to need to install X Windows (X11). The Yum command for this is:
Code:
yum -y groupinstall "X Windows Desktop Manager"
and remeber, this is all case-sensitive, barring your use of some weird file system.

pretty simple so far. Now you can choose to use X Windows as your window manager, it's fairly lightweight and works ok for what you need to do here, but I chose to install XFCE on top of X11. The Yum command is:
Code:
yum -y groupinstall XFCE

Now, verify that you have vncserver installed using this command:
Code:
rpm -a | grep "vncserver"

If it's not installed, the yum command to install it is
Code:
yum -y install vncserver

Alright, now configure VNCServer. Open the config file like this:
Code:
vi  /etc/sysconfig/vncservers
and then edit that file to look like this:
Code:
$ vi /etc/sysconfig/vncservers

# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.

# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.

# Use "-nohttpd" to prevent web-based VNC clients connecting.

# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.

VNCSERVERS="1:USERNAME"
VNCSERVERARGS[1]="-geometry 1024x768 -depth 16"
where USERNAME is the user you want to login to this VNC session. This should be a user already added to and with permissions on the box. The server args should be self-explanatory. Set your resolution and color depth, if desired.

Save that file and type:
Code:
$ vncpasswd
Password:
Verify:
to set your VNC password.

Cool, VNC should be all setup. Start your VNC server instance like so:
Code:
$ vncserver :#
Where # is the number you put next to the username in that config file we edited.

Now, whatever the number was (above I left it as one), this is added to the port we will use to login to the server. In this way, you can use several accounts for VNC access. So if the server is 1, the base port of VNC is 5900, so the port we'll use to connect is 5901. Most VNC clients nowadays are smart enough to figure this paradigm out on their own, but if yours isn't, now you know.

Now the server is started and a user could connect, however they will get a plain grey desktop by default as the connection will not cause a new
session of X to start by default, to fix this we need to edit the startup script in the .vnc folder in your home directory.
Code:
$ vi ~/.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
As you can see above, you need to uncomment the two lines right below where it says "# Uncomment the following two lines for normal desktop:"

Alright, now kill your vncserver and restart it, and open up a VNC viewer to make sure everything is going smoothly.

Once you can, login and go download virtualbox or your virtualizing software of choice. I prefer virtualbox because (surprise) it's FOSS. Also using vBoxManage, you can do some neat stuff with port and IP forwarding whilst running a virtual server.

The rest should be pretty self-explanatory, but you'll need to rip an ISO of windows XP or whatever OS you want and then upload it to your dedicated server, then set virtualbox/zen/VMWare Workstation/whatever to have that "disc" (ISO) in its CD drive. From here on out, it's pretty much a breeze, but don't hesitate to post here if you need help.

-V

Some instructions for VNC taken from here: bobpeers.com/linux/vnc.php
« Last Edit: June 02, 2008, 12:07:26 PM by vsloathe » Logged

hai
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: May 31, 2008, 07:17:16 PM »

How to forward ports to the virtual machine can be seen here:

http://sk.c-wd.net/wp/2008/01/05/virtualbox-port-forwarding-with-linux-host/
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: June 01, 2008, 05:13:44 PM »

Sweet workup VS... I can't see a lot of need for that, but damn good to know if someone did. That's not a HelloWorld example. Well done.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #3 on: June 01, 2008, 06:01:33 PM »

Thanks Perk. Trust me, when I have time, I'm going to de-windoze-ify this particular piece of code, but right now it's a time thing.
Logged

hai
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #4 on: June 02, 2008, 07:12:12 AM »

To enable VNC to the guest OS:

First make sure you disable any firewall that's present on the guest OS, then type these commands into your console:

Code:
VBoxManage setextradata name_of_vm "VBoxInternal/Devices/pcnet/0/LUN#0/Config/vnc/HostPort" 6900
VBoxManage setextradata name_of_vm "VBoxInternal/Devices/pcnet/0/LUN#0/Config/vnc/GuestPort" 5900
VBoxManage setextradata name_of_vm "VBoxInternal/Devices/pcnet/0/LUN#0/Config/vnc/Protocol" TCP

Now you can VNC in to the guest OS straightaway on port 6900.

Here's a screenshot of my VNCed right in to the WinXP box running virtualized on FC6.


* RD.png (42.88 KB, 1278x745 - viewed 511 times.)
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: June 02, 2008, 09:41:26 AM »

That last piece makes it most usable IMO... Windows doesn't like being controlled from the command prompt, and the apps you'd want to run you'd prolly have to go that way anyway. Nice again man.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #6 on: June 02, 2008, 12:06:34 PM »

You should get mad search engine love from this piece. I worded the title the way I did for a reason lol.

I was going to write it on my blog, but then I was like "meh, I already have The Cache open", and laziness won out.
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: June 02, 2008, 12:39:33 PM »

 Smooch
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
maggiemae
Rookie
**
Offline Offline

Posts: 23


View Profile
« Reply #8 on: September 05, 2009, 11:05:22 AM »

Re vps  -  I think I can follow directions, maybe.  Have to get cracking as I am running out of time.   I found this web hosting - batcave.net - pretty cheat vps starter plan - $17  PM or $170 a year.  Ever heard of them?  They are located in Europe which is fine by me.  I am checking with them on ip address location.

Jees I sure am busy for a retired old person.  Next month I have to have cataract surgery/ both eyes.  Got tired of getting larger and larger cmpt screens and TV's.  Hurray for our Canadian Health care system!

Anyway. thanks for your posts, please leave the instructions up.

Maggie
Logged

Maggie
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #9 on: September 05, 2009, 12:26:19 PM »

17/month.

woot another VPS to put my turds on.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!