November 14th, 2008 admin
Suppose you’re at an open wireless hotspot and wish to connect the Samba server from your Windows laptop, but you don’t want to send data (documents, authentication hashes etc.) over the air in plain text.
Using SSH tunnels, you can encrypt all your network traffic and redirect it through a trusted computer when you’re connected to an untrusted network. The goal of this hack is to enable Windows users securely access shared files on any Samba server.
So, what are SSH Tunnels? In addition to providing remote shell access and command execution, SSH servers can forward ports to the other end of your connection. This can be extremely useful to protect any traffic that you need to keep private. In a nutshell, it is accomplished by binding to a local port, encrypting the traffic, sending the encrypted data to the remote machine, and then decrypting it and sending it to the remote host and port you specify.
Samba and Windows use port 139 for file sharing. At first glance, it seems that the easy solution is to tunnel connections from port 139 on your Windows computer to the Samba server. Then you can easily connect to the remote share by connecting to “localhost”. But since Windows always uses port 139 for file sharing, you must disable local file sharing to make the port forwarding.
So, how do we tunnel SMB over SSH and keep local file sharing working? We’re going to use a virtual network adapter. Basically, a virtual network adapter is a software application that allows a computer to connect to a network. We’re going to add a virtual adapter to our Windows computer and create a SSH tunnel over the virtual interface.
To add a virtual network adapter in Windows, use the following steps:
- In the Control Panel click on Add Hardware.
- In the Add Hardware Wizard, select “Yes, I have already connected the hardware” and click Next. Scroll down the list and click on “Add a new hardware device”.
- Select “Install the hardware that I manually select from a list”. From the hardware types, select Network Adapters and choose Microsoft Loopback Adapter.
- Go through the installation procedure.
The next step is to configure the new virtual adapter.
- Go to Network Connections configuration panel.
- Right click on the Microsoft Loopback Adapter and select Properties.
- Select Internet Protocol (TCP/IP) and click on the Properties button.
- Check “Use the following IP address” option and enter the chosen IP address (e.g. 10.0.0.1) and the subnet mask (255.255.255.0). If you have a gateway and DNS servers in your network, enter them too.
- Click on the Advanced button and in the WINS tab, select “Disable NetBIOS over TCP/IP”.
Setup the SSH Tunnel
Now that you have a properly configured virtual adapter, it’s time to setup the SSH tunnel between the Samba server and your computer. We assume that OpenSSH is already running on the Samba server. For the SSH client software we’re going to use Putty, a free SSH client that supports port forwarding.
Fire up Putty on your computer and enter the host name or IP address of your Samba server (e.g. 192.168.0.104). In the Tunnels options, in the “Source port” type 10.0.0.1:139 (the IP we used in our example) and in the “Destination” type 127.0.0.1:139. Click on “Add” and then “Open”. Once you authenticate, you’re ready to access the Samba server over the virtual adapter.
To test your SSH tunnel, just navigate from Windows explorer to \\10.0.0.1. If everything goes well, you’d prompted to enter a username and password to access the shares. Enjoy!

When things go wrong
If things don’t work, make sure that both Samba and Putty are running and properly configured. If you’re running Windows XP SP2 in a closed environment (no access to the Internet for updates), make sure to install KB884020.
Posted in Linux, Settings | Comments Off on Tunneling SMB over SSH: Secure file sharing
November 2nd, 2008 admin
It is scary to realize that it is next to impossible to delete all the data that one stores on ones storage media without completely destroying it. Because, with the right tools anybody can retrieve even deleted data.
So what can be done to alleviate the situation ? If you are using GNU/Linux or any other UNIX, then you have a tool called shred which can be used to wipe all the data from the hard disk. Here is how it works. Suppose I want to erase all the data on my hard disk, then I boot using a LiveCD like Knoppix and open a shell and type the following command:
# shred -vfz -n 100 /dev/hda
Here /dev/hda is my whole hard disk. And I am asking shred to make (-n) 100 passes by overwriting the entire hard disk with (-z) zeros. And shred program (-f) forces the write by changing the permissions wherever necessary.
Another GPLed tool (though not specifically related to Linux) which is quite popular is Darik’s Boot and Nuke (DBAN) which also does a swell job of wiping ones hard disk.
It is claimed that experts in the field of retrieving data can still get some data from a hard disk that has been wiped in the above manner. But atleast lesser mortals who buy second hand laptops and computers will find it beyond their means to lay their hands on the data.
Posted in Linux | Comments Off on How to securely erase the hard disk
October 22nd, 2008 admin
- Microsoft Windows users running Microsoft Internet Explorer 6.x and 7.x can delete their history files by clicking the “Tools” menu, “Internet Options”, and clicking the “Delete Files” or “Delete” button. Users also have the option of automatically deleting files each time the close the browser window by clicking the “Advanced” tab and checking “Empty Temporary Internet Files folder when browser is closed” under the “Security” section.
- Microsoft Internet Explorer 4.x users on an Apple Macintosh can delete the history by clicking the “Hard Drive” icon, “System”, “Preferences”, “Explorer”, and moving the history file into the trash.
- Microsoft Internet Explorer 3.02 and lower users can delete their history by clicking the “View” menu, “Options”, open the tab “Advanced”, click the “Settings” tab, and click the “Empty Folder” button.
Posted in Customer applications | Comments Off on Flush Internet Explorer browsing history and cache
July 5th, 2008 admin
First some basic cheats, so you don’t have to search through the whole post:
ctrl+a+c make a new screen
ctrl+a+n next screen down the line
ctrl+a+p previous screen down the line
ctrl+a+k kills current screen until last one then you’re out
ctrl+a+d leave, but leave them running and re-attachable
screen -ls 31619.something.else (Detached)
screen -r 31619.something.else re-attaches to that session
screen -DDR to re-attach any (the first) detached session.
If there is none, it creates a new session.
If you’ve ever used SSH to connect to a server, you ‘ll know its limitations: if you want to open a new window, you’ll need to create a second SSH connection to the server. And if the connection breaks during the SSH tunnel, you’ve lost your progress. This is where Screen comes in.
Screen, which calls itself a “full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).” is a usefull tool to use 1 SSH connection, but use multiple screens to work in. So you can have 1 screen to write some scripts in, another to tail a logfile and a third to check your IRC messages 😉
Screen is installed by default on most installations, you can verify this by running the “which screen” command. If it’s not installed, try to apt-get or yum it – it’s in most repositories.
You can start screen by typing:
[root@vps ~]# screen
This makes sense, right? 🙂
You’ll probably notice that not much happens if you type that. At least, it seems like not much as happened. In fact, you’ve just opened a new “screen” to type your commands. The program “screen” has a few commands of its own, in order to create a new window, and navigate through the open ones.
Once you’ve opened “screen“, you can see a command list by typing “CTRL + A”, followed by “?” (the question mark). By typing “CTRL + A” you state that the next signal is to be sent to the program “screen“, in stead of to the Shell (like you would in a normal shell). You’ll see a list of all bindings known to “screen“.
Start a new window by typing “CTRL + A” + “c”. The C stands for Create – I know, too obvious. A new window will be created. In order to test this, type the command “top”. Then create a new window, by using “CTRL + A” + “c”. You’ll see top disappear, and a new window will open. Type in some commands of your choice, and return to the previous window, by doing “CTRL + A” + “n”. The “n” stands for “Next”, and will open the next screen. “CTRL + A” + “p” would’ve opened the previous screen.
Closing a window, can be done by typing “exit” (like you would in a normal shell). This will cause you to fall back to the previous monitor you opened, or to your main prompt – where you started screen, showing you a message such as “[screen is terminating]” – so you’ll know you’ve hit the main shell.
The biggest advantage in using screen, is that you can “detach” a screen-session. This means you return to the normal shell, but the processes started in “screen” are still active in the background. You can detach yourself by typing “CTRL + A” + “d”. Again, obvious that “D” stands for Detach. This gives you more flexibility for managing your server(s): you can start a number of processes, quietly exit the shell and return a couple of hours later to pick up the session started in screen.
Should you disconnect by accident, during a screen-session, you can always pick up a previous screen by relogging to shell and typing “screen -ls“. This will show a list of all running screen-sessions at any given time. You can pick up a previous screen-session, by typing “screen -r <name_of_session>“.
Probably known to most linux-administrators, but still an awesome tool 🙂
Re-printed (so we don’t loose the information) from:
http://www.mattiasgeniar.be/2008/06/04/screen-a-must-for-ssh/
Posted in Linux | Comments Off on Screen? A must for SSH
June 24th, 2008 admin
This application will let you share your Windows machine’s desktop with others.
Posted in Customer applications | Comments Off on Remote Windows Desktop Support
June 2nd, 2008 admin
Concepts Files & directories
- Everything is a file
- 256 characters maximum
- Case sensitive
- Special characters
- Begin with . (period)
- Don’t use /, ?, *, –
- Avoid spaces; use underscores instead
- Extension not necessary
File system
- Hierarchical tree
- No drive letters
- Starts at root with /
Getting Information
man
man [command]
Within man:
- spacebar/f = forward
- b = back
- q = quit
- / = search forward
- ? = search backward
- n = repeat search
info
info [command]
info info
Enter ‘m’ & enter program name
Viewing Files
cat
Display file to STDOUT
cat [file]
more or less
Display STDOUT screen by screen
more [file]
less [file]
Within more:
- spacebar/f = forward
- b = back
- q = quit
ls | less
head
View the first lines of a text file
head file.txt = show first 10 lines of file
head -25 file.txt = show first 25 lines of file
tail
View the last lines of a text file
tail file.txt = show last 10 lines of file
tail -25 file.txt = show last 25 lines of file
Getting Around
cd
cd ~
cd .
cd ..
ls
ls -a
ls -l
lrwxrwxrwx # owner group size_in_bytes last_modified_date_&_time filename.txt
^\_/\_/\_/
| v v v
| | | |
| | | World permissions
| | |
| | Group permissions
| |
| Owner permissions
|
Type of file:
- = file
l = link
d = directory
b = block device (disk drive)
c = character device (serial port or terminal)
ls -la
ll
ls -F
Classify special files with a character after the file name
- * = executable
- / = directory
- = = socket
- @ = alias
- | = FIFO
- No character = normal file
ls [directory name]
pwd
Display absolute path
pwd
Changing Permissions & Ownership
chmod
r = read = 4
- If file: view contents
- If directory: list contents
w = write = 2
- If file: modify
- If directory: add or remove files
x = execute = 1
- If file: run file as command
- If directory: access files contained inside
u = user
g = group
o = others
a = all
chmod 744 file
chmod -r 744 file
chmod a+x file
chmod a-x file
chmod a+rw-x file
chown
File Information
chown [username] file
chown [username].[groupname] file
file
file [filename]
od
Octal dump of files
Files & Directories
cp
cp /path/to/file /path/to/new/file
cp /path/to/file .
cp file directory/
cp -F
cp -r directory/ directory/
cp -i file file
mv
mv file newfile
mv file directory/
mv directory/ directory/
mv -i file file
mkdir
mkdir [directoryname]
rm
rm file
rm *
rm -i filename
rm -r directory
rm -f file
rm -rf directory
rm -rf /*
Do NOT do this!
rmdir
rmdir
Note: directory must be empty; since that’s often a pain, you can use “rm -rf directory-name” instead, but be careful!
ln
ln [original_file_name] [new_file_name]
Creates a hard link
ln -s [new_file_name] [original_file_name]
Creates a soft link
Finding
find
find / -name *gnome* -print
find / -type d -maxdepth 1
find -name [name] -group [group] -size [size] -mtime [number of days ago] – type [b|c|d|f|l]
locate
locate file-or-directory
updatedb
Update the database used by the “locate” command
whereis
whereis [command]
System Information
free
How much memory is used & unused
Note that you can use this to get even more info: cat /proc/meminfo
df
Disk usage for all mounted drives
du
Disk usage for the current directory and all subdirectories
du -h
Show results in human-readable form (kb & MB)
These details were copied from:
http://www.granneman.com/techinfo/linux/commandline/basiccommands/
Posted in Linux | Comments Off on Basic Linux Commands
February 10th, 2008 admin
Most of the program files you need to install on your machine will be downloaded in a compressed format that takes less time to transfer. Once on your machine, you will need to uncompress the file before you can install it. First, determine the type of file you have from the file suffix. If it ends in .tar it is probably an unzipped tar file. If it ends in .Z, .gz, .bz2 or.tgz it is probably a zipped tar file (zipping is a form of further compression). In order untar a tar file type:
tar -xvf file.tar
if it is a zipped tar file add a z to the options:
tar -zxvf file.tar.Z (except for bz2 which uses -j instead of -z)
If you want to look at the contents of a tar file before you untar it use:
tar -t filename.tar
If you then decide there is only a small part of the total tar file you actually need to extract, type:
tar -zxvf tarfile filepathIf you have a large number of files you wish to transfer you can make it simpler by tarring them first:
tar -cvf file.tar directory_to_tar
(Make sure you don’t reverse the order of “file.tar” and “directory_to_tar”). Then to zip it type:
gzip -cv file.tar
Or better yet, do it all at once with:
tar -zcvf
On our SGIs, this must be done with the command:
tar -tvf file.tar directoryname instead.
Here’s a neat trick for transferring a tar file to another machine that will tar “on the fly” rather then requiring you to create a tar file on your own machine first. (Which can be useful if you don’t have much space left.) To do this simultaneous tar, zip, and transfer type:
tar --rsh-command=`which shh` -zcvf -- --host_computer:filename.tar -- --directory_to_tar
Note that “which ssh” needs back-ticks rather than apostrophies.
After you uncompress a program tar file you will usually still have to install the program yourself. The usual directory to install programs in is /usr/local/. (You will need root permissions.) Look for a README file in the file’s source code to get further instructions.
An easier method of installing programs though is to get a rpm package rather then a tar file for a program whenever possible. Rpm packages do all the work of untarring and installing for you. A good source for these files can be found at: http://linux.s390.org/download/rpm2html/index.html or ftp://ftp.software.umn.edu/pub/linux/redhat/redhat-9-en/os/i386/RedHat/RPMS
(Note that this particular link is for people using Redhat 9 but if you go up a few directories you can get to the directory specific to the LINUX version your using).
tar zcf localfolder.tgz localfolder/
tar zcf - localfolder/ \ | ssh 192.1.1.1 "cd folder/to/copy/to; tar zpxvf -"
gzip -dc file.tar.gz | tar xf - pathname/filename
The pathname and filename should be exactly as given in the .tar.gz file. If you want more than one file append their names, again include pathname, at the end of the command.
Posted in Linux | Comments Off on TAR & zipping
February 10th, 2008 admin
In addition to editors like emacs, you can also edit files directly from the terminal using sed, the built-in stream editor. You can use it to make substitutions or deletions in a file with commands such as:
sed 's/oldword/newword/g' filename
which substitutes “newword” for “oldword”. The “g” makes the substitution global (all instances on that line). Without the g, it will only change the first match on that line.
Other sed commands:
sed 's/word/d' filename
This deletes the whole line, not just the word. To delete just the word:
sed 's/word//' filename
The examples given will print out the changes to the terminal. If you want to print the changes to a file instead type:
sed 's/oldword/newword/' filename > newfilename where > directs the output into a file called newfilename
To link more than one command together use &&. For example:
sed 's/oldword/newword/' filename > newfilename && emacs newfilename
|
sed ‘s/string1/string2/g’ |
Replace string1 with string2 |
|
sed ‘s/\(.*\)1/\12/g’ |
Modify anystring1 to anystring2 |
|
sed ‘/ *#/d; /^ *$/d’ |
Remove comments and blank lines |
|
sed ‘:a; /\\$/N; s/\\\n//; ta’ |
Concatenate lines with trailing \ |
|
sed ‘s/[ \t]*$//’ |
Remove trailing spaces from lines |
|
sed ‘s/\([\\`\\”$\\\\]\)/\\\1/g’ |
Escape shell metacharacters active within double quotes |
• |
seq 10 | sed “s/^/ /; s/ *\(.\{7,\}\)/\1/” |
Right align numbers |
|
sed -n ‘1000p;1000q‘ |
Print 1000th line |
|
sed -n ‘10,20p;20q‘ |
Print lines 10 to 20 |
|
sed -n ‘s/.*<title>\(.*\)<\/title>.*/\1/ip;T;q‘ |
Extract title from HTML web page |
|
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n |
Sort IPV4 ip addresses |
• |
echo ‘Test’ | tr ‘[:lower:]’ ‘[:upper:]’ |
Case conversion |
• |
tr -dc ‘[:print:]’ < /dev/urandom |
Filter non printable characters |
• |
history | wc -l |
Count lines |
Posted in Linux | Comments Off on File editing with SED
February 8th, 2008 admin
The document describes how you can manage your Blue Net MySQL database.
Note:
Database structure and design are outside the scope of this document and are not covered.
To manage your database you require the following information:
Database server:
mysql01.blue.net.au
Database user name and password are allocated upon signup with Blue Net hosting
You can then either use the built-in manager at:
http://support.blue.net.au/phpmyadmin
For instructions on how to use PHPmyAdmin please refer to: http://www.phpmyadmin.net/home_page/docs.php
Alternatively we recommend the excellent, free OpenSource HeidiSQL:
http://www.heidisql.com
Please refer to their extensive user forum for support and instructions for this product.
Posted in Settings | Comments Off on Managing the Blue Net MySQL database
February 5th, 2008 admin
There are a couple of things missing from the otherwise very stable CentOS5:
denyhosts
A python script checking on failed attempts to log into SSH and blocking IP addresses in /etc/hosts.deny when detected.
psad – www.cipherdyne.com/psad/
port scan admin, which detects port scanning activity and blocks IPs with iptables when detected
Additional updating and facilties (like the ones above) are easier installed with YUM when the following repo (Centos, Linux Enterprise & RedHat 7.3 & 9) is added:
http://dag.wieers.com/rpm/FAQ.php#B
Posted in Linux | Comments Off on centos 5 tweaks