My Quick Guide for a Linux setup on VMWare (Ubuntu/Debian)

This post is written for Debian but will work for other Debian based linux distros like Ubuntu. Debian is my personal favourite as it is stable, clean, fast and easy-to-use/configure. There is a wealth of information about Debian on the net, and the debian.org web-site is quite comprehensive and helpful.

So you have installed a Debian 5 (Lenny) distro on a virtual machine in VMWare and cygwin on your windows desktop. This is a quick guide (doubles as a reference/reminder for myself) on how to install stuff and get you going.

As stated above I assume this is where you are:
  • You've downloaded an ISO image from your favourite distro web-site (Ubuntu/Debian).
  • You have installed the distro on a VMWare instance and you gave it a name (e.g. 'debian5')
  • You have a 'root' account and your own named account (e.g. 'username'), advisable to use the same username you use for Windows (helps when accessing your computer from cygwin)
  • You have cygwin installed on your PC. (I will need to write a guide for cygwin installs one day)
  • You have WinSCP and Putty installed somewhere on your PC.
On your Linux box, through the VMWare console, open a shell and log in as root:

su - root

Update your system and install ssh:

apt-get update
apt-get install ssh

Find out what the IP address of your linux install is by typing:

ifconfig

On your PC now, edit the %SYSTEMROOT%\system32\drivers\etc\hosts file and add an entry for your linux box, i.e.:

192.168.xx.xxx debian5

where 'debian5' I assume is the name of your machine.

Ensure you can ping your Linux box from your PC command line:

ping debian5

After this, you can open a WinSCP session to your linux box to verify that ssh is working properly (for the time being).

Now, the next thing I do, is to open the .bashrc file from the root's home folder and add the following lines:

export PS1='\n\[\033[1;31m\]\u\[\033[1;37m\]@\[\033[0;31m\]\h\n\[\033[0m\][\[\033[1;33m\]\w\[\033[0m\]] '
umask 077
alias l="ls -lFa --color=auto"


This gives you a nice prompt and a nice alias for "l".

Do the same for your named user, edit /home/username/.bashrc and add:

export PS1="\n\[\033[1;36m\]\u\[\033[1;37m\]@\[\033[0;36m\]\h\n\[\033[0m\][\[\033[1;33m\]\w\[\033[0m\]] "
umask 077
alias l="ls -lFa --color=auto"

This gives you a different color for the prompt for your named user.

At this moment, we have SSH installed and we can connect to our Linux virtual machine from Windows using WinSCP or cygwin (try ssh -l username debian5). I now much prefer to minimize VMWare and use cygwin, Putty and WinSCP for the rest. We can fully administer our Linux install using these tools and we don't have to use the mouse too much. Such fun!

From cygwin try:

ssh debian5 (<-- this uses your named account (good to have macthing usernames for Windows/Linux) ssh -l root debian5 or ssh root@debian5

I now usually create a '/u01' folder where all my machine-wide stuff goes, like special installations of java, tomcat, and other tools that are not OS related go.

Logged in as root:

groupadd admin
mkdir /u01
chown username:admin /u01
chmod 774 /u01


Using ssh with Public Key Authentication

On your PC (client), you need to generate a key pair. Using cygwin type:

ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ksymeon/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ksymeon/.ssh/id_rsa.
Your public key has been saved in /home/ksymeon/.ssh/id_rsa.pub.
The key fingerprint is:
e8:bb:5f:d5:e0:f1:49:88:01:38:c1:cd:7d:b4:94:99 xxxxxxx@xxxxxx

You now have the public and private keys in your .ssh folder on your cygwin install.

Next thing to upload your public key to your linux box. The content of your public key needs to be added to the ~/.ssh/authorized_keys2 file on your linux box. You can have multiple authorised keys for your account. I use different keys for each different machine I use to connect to my servers, i.e. my laptop has a different key than my desktop.

Using cygwin log in to your linux box:

ssh debian5

Create the .ssh folder under your home (~) folder:

mkdir .ssh
chmod 700 .ssh

Open another local cygwin shell, copy your public key securely to your linux box:

scp id_rsa.pub debian5:~/.ssh/temp.pub

From your remote cygwin shell, get into your .ssh folder and check the temp.pub is there:

cd .ssh
ls -lFa

Append the public key to your authorised keys and delete it:

cat temp.pub >> authorized_keys2
rm temp.pub

Now, back to you cygwin prompt, try to ssh again into your linux box:

ssh debian5
Enter passphrase for key '/home/xxxxxx/.ssh/id_rsa':

You see that instead of your password, the passphrase is required.

You can now add your public key to other accounts, for example the root account if you would like to log in as root directly from your PC. Otherwise you can always log in as yourself and 'su - root' after you are in.

This is as far as I can go now, more to come in a different post.

Comments

psarog said…
I left your post around this sentence: "Debian is .... and easy-to-use/configure"

Popular posts from this blog

Useful Fonts for Linux

CyLog Raster Fonts for Linux

Chrome Packaged Apps