Archive for September, 2008
Bypass firewalls using ssh and tunnelling.
Ever wanted to access a service behind a firewall that has port 22 open for ssh connections? This is a common setup known as using a jump-box for security access and to be successful at this we your firewall must allow port 22 traffic to your ssh jump-box. We can test our if port 22 is open by typing the following line.
telnet ssh-jump-box 22
If all is good then we should see something like
Trying 192.168.1.200...
Connected to ssh-jump-box.
Escape character is '^]'.
SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
In this example we’re going to create a tunnel for port 3389 windows rdekstop and we’ll begin by creating a local loopback port 3390 that ssh will tunnel from myMachine to myFireWalledMachine on port 3389
ssh -L 3390:server-behindFirewall:3389 user@ssh-jumpbox -N
Now we can access the service on port 3389 that was previously inaccessible through the firewall by pointing our connection to the local loopback port we just created through ssh. In this case we\’ll use rdesktop to hit that port as we are trying to remote desktop to a firewalled machine.
rdesktop localhost:3390
Access a microsoft windows share from the bash terminal in Ubuntu Linux Desktop
Setup
Ever want to access a windows share from your terminal? Well using ‘ mount ‘ and cifs/samba this is a snap.
Make sure you have smbfs/cifs support, on ubuntu linux distributions you can simply type
apt-get install smbfs
Now we need to make a directory on our hard disk where we can mount our windows share.
mkdir /mnt/location
Mounting Windows Share
Now we\’re ready to mount the filesystem on our newly created directory (/mnt/location).
Mount with cifs
mount -t cifs //server-ip-or-name/share /mnt/location -o username=user,password=pass,domain=DOMAIN
Mount with smbfs
mount -t smbfs //server-ip-or-name/share /mnt/location -o username=user,password=pass,domain=DOMAIN
Clean Up
When finished with our windows mount, we should exit the directory, or close any windows that are accessing it, and then unmount the Microsoft Windows NTFS share by using the following series of commands.
cd /; umount /mnt/location
Using find to search files on your system
Looking for something? Find has all the power you’ll need to locate any file or directory on your system, as long as you know the name of what you’re trying to find.
First you’ll need to launch a terminal session, and then we’ll dive into this by typing the following command.
find / -name 'my-file.txt' 2>/dev/null
Breaking down our ‘ find ‘ command
- ‘ / ‘ - is our search location, since we’re using / it’ll search everything on our root partition
- ‘ -name ‘ - says we’re gonna search by name, and we can type anything in here (* wildcard)
- ‘ 2>/dev/null ‘ - will tell the shell to pipe all errors to dev/null meaning they wont be displayed