Ssh tunnel through Window and Linux with port forwarding and proxy socks

Monday, 13 December 2010 16:06 by myro

 

This is just a reference guide to accomplish a ssh tunnel and I'm assuminig that you already know what a ssh tunnel is. Otherwise take a read at wikipedia: http://en.wikipedia.org/wiki/Tunneling_protocol  and google a little bit :)

Create an ssh server in Windows:

Let's first create a ssh server in windows (I have tested that it works fine with win 7) 

  1. In you window machine download and install FreeSSHd: http://www.freesshd.com/?ctt=download .
  2. Run the executable and install it into your windows computer. Let the installer creates the required keys. (do not install it as a service, because when you will need it, you will run it by yourself.. right?).
  3. Launch the program: start->freesshd->freesshd. after the icon tray appears, right click it and press settings.
    If you experience  problems with the windows UAC, run it as administrator.
  4. Make sure that the ssh server is running under the server status tab.
  5. Click the Tunneling tab and flag as following:
    Allow local port forwarding = yes
    Allow remote port forwarding = yes
  6. Under Users tab, click Add and create a sample user as following:
    Login: test
    Authorization Pasword stored as SHA1 hash
    Password: test
    User can use:
    -SSH = yes
    -Tunneling = yes
  7. Click OK to save and close the window.
To make sure that your SSH server works, download putty  and try to connect. You should connect to localhost at port 22 and when the login is prompted just use username "test" and set the password to "test".

Create an ssh server in Linux:

  1. install openssh-server :)
    if you are using Debian as me, just type apt-get install openssh-server as root
  2. make sure that you can ssh to it with a valid login 

Create the tunnel 

I will describe how to create the tunnel in linux, because my primary laptop is a  Debian box. If you are using windows, there are so many guides over the net... just try to figure out how to do that with Putty.

 Port Fordwards

You will forward all your local request to your ssh server

 ssh user@yourSshServer -L LocalPort:remoteAddressToReach:RemotePortToReach -N

Let's see in details:
 user@yourSshServer : is the user that will be used to connect to the ssh server. If you have created the ssh server in windows, just use test@yourWinIpCompuer

-L    creates the port forwarding
       -LocalPort:RemoteAddressToReach:RemotePortToReach means:
       -LocalPort: you are making the port forwarding from your local port 9999 (localhost:9999)
       -RemoteAddressToReach: the address you want to reach
       -RemotePortToReach: the remote port you want to reach

-N prevents running command through ssh 

So if you want to RDP (Remote Desktop) a server named sampleserver.com you will run:

ssh test@sshServerIp -L 9999:sampleserver.com:3389 -N

Now I can connect and rdp the server using localhost:9999

SOCKS Proxy

Unfortunalty this is not possible if you want to use your ssh server for browsing the web, because most of websites replies on specifics host headers as defined in the http 1.1 protocol.
What you need here is to set up a local socks server which will translate every http request.
 
ssh user@yourSshServer -D localhost:9999 -N 

Let's see in details:
 user@yourSshServer : is the user that will be used to connect to the ssh server. If you have created the ssh server in windows, just use test@yourWinIpCompuer

-D localhost:9999 binds the socks proxy on local port 9999

-N prevents running commands through ssh

Once you have launched this command, open your browser and configure to use the socks proxy.
In firexfox go under Edit -> Preferences -> Network -> Settings:

 
And you are done! 

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Linux
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed

Debian Squeeze: mount windows share using CIFS

Sunday, 12 December 2010 14:24 by myro

To mount a remote share In Debian Squeeze, make sure that cifs-utils is installed, otherwise you would receive the following error:

 mount: wrong fs type, bad option, bad superblock on //x.x.x.x/share

 to install cifs-utilis, just use apt-get:  apt-get install cifs-utilis.

Now you can mount the share on your local filesystem:
mkdir -p /mnt/yourShare
mount -t cifs //x.x.x.x/share/ -o username=username,password=password /mnt/yourShare 
-o iocharset=utf8,file_mode=0777,dir_mode=0777

If you want to mount this share automatically when your system loads, just add this line to your /etc/fstab file:

//x.x.x.x/share/mnt/yourShare   cifs  credentials=/root/.credentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

As you can see, I'm not writing the credentials directly in fstab file because this file can be viewed by anyone. To store your credentials in /root/.credentials, do:

sudo nano  /root/.credentials

and add the followin text:

username=your_smb_username
password=your_smb_password

 

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Linux
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed

Debian Lenny - set proxy for apt

Tuesday, 1 June 2010 12:20 by myro

If you need to set up a proxy into your debian machine you should open you terminal and run the following command:

HTTP Proxy
export http_proxy="http://USERNAME:PASSWORD@PROXYSERVER:PORT"

FTP Proxy
export ftp_proxy="ftp://USERNAME:PASSWORD@PROXYSERVER:PORT"


hope it helps

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Linux
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed

Get your linux computer system summary

Tuesday, 28 July 2009 20:01 by myro

In this post, I'm going to show you som common shell command in linux that can helps you in obtaining your computer summary. This commands are useful if you expect a problem with your linux distribution, but you don't know where you should start in solving your problem.

Print system information

uname -a
Linux debian 2.6.30-bpo.1-686 #1 SMP Sun Jun 28 18:13:49 UTC 2009 i686 GNU/Linux

List all PCI devices

lspci -v -nn
00:00.0 Host bridge [0600]: Intel Corporation Mobile 4 Series Chipset Memory Controller Hub [8086:2a40] (rev 07)
    Subsystem: Sony Corporation Device [104d:9035]
    Flags: bus master, fast devsel, latency 0
    Capabilities: [e0] Vendor Specific Information <?>
    Kernel modules: intel-agp

00:01.0 PCI bridge [0604]: Intel Corporation Mobile 4 Series Chipset PCI Express Graphics Port [8086:2a41] (rev 07) (prog-if 00 [Normal decode])
    Flags: bus master, fast devsel, latency 0
    Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
    I/O behind bridge: 00006000-00006fff

.......

List the status of modules in the Linux Kernel

lsmod
Module                  Size  Used by
binfmt_misc             7080  1
rfcomm                 30184  0
l2cap                  18112  5 rfcomm
bluetooth              46860  4 rfcomm,l2cap
vboxnetadp             66816  0
vboxnetflt             72288  0
.....

Cpu informations

cat /proc/cpuinfo
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 23
model name    : Intel(R) Core(TM)2 Duo CPU     P8400  @ 2.26GHz
stepping    : 6
cpu MHz        : 800.000

.....

Cpu frequency kernel information

cpufreq-info
cpufrequtils 004: cpufreq-info (C) Dominik Brodowski 2004-2006
Report errors and bugs to cpufreq@lists.linux.org.uk, please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which need to switch frequency at the same time: 0
  hardware limits: 800 MHz - 2.27 GHz
  available frequency steps: 2.27 GHz, 2.27 GHz, 1.60 GHz, 800 MHz
  available cpufreq governors: powersave, userspace, conservative, ondemand, performance
  current policy: frequency should be within 800 MHz and 2.27 GHz.

......

List of currently registered port regions used for input or output communication with a device

cat /proc/ioports
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-0060 : keyboard
0064-0064 : keyboard
....

List number of interrupts per IRQ

 cat /proc/interrupts
            CPU0       CPU1      
   0:     311925     315345   IO-APIC-edge      timer
   1:       1584       1525   IO-APIC-edge      i8042
   8:         39         44   IO-APIC-edge      rtc0
   9:       2288       2253   IO-APIC-fasteoi   acpi
  12:         65         66   IO-APIC-edge      i8042
  16:         32         24   IO-APIC-fasteoi   uhci_hcd:usb1, uhci_hcd:usb6, firewire_ohci
  17:         12         13   IO-APIC-fasteoi   mmc0, HDA Intel

....

List USB devices

cat /proc/bus/usb/devices

T:  Bus=08 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 8
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 2.06
S:  Manufacturer=Linux 2.6.30-bpo.1-686 ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=0000:00:1d.7
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

....

List USB bus devices:

lsusb

Bus 008 Device 004: ID 054c:0377 Sony Corp.
Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 05ca:183d Ricoh Co., Ltd
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 007: ID 04b8:010b Seiko Epson Corp. Perfection 1240
Bus 003 Device 006: ID 046d:c01d Logitech, Inc. MX510 Optical Mouse
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

I will try to keep this post updated as soon as i learn something new.. in the meanwhile, i want to say thx to http://www.klabs.be/ for prividing me this informations.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Linux
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed

Install OpenOffice 3.1 on Debian Lenny 5.0

Monday, 1 June 2009 12:35 by myro

Installing OpenOffice 3.1 in Debian Lenny 5.0 is simple and you get all your Icons set in Gnome without the need of manually setting up links. What you need to do is:

  • Using Synaptic Manager, remove your old OpenOffice (mine is 2.4) installation
  • Download your .deb packages from http://www.openoffice.org/
        Start downloading OpenOffice.org 3.1.0 for Linux Debian in US English
        (Java runtime, JRE, included for all OS versions except Linux Deb and Mac)
  • Unpack all those .deb that comes from your download into a folder.
  • Open a terminal session into your new folder that contains the debs and type:
      dpkg -i *.deb
  • Move the the subfolder called desktop-integration and retype
      dpkg -i *.deb
  • Now your OpenOffice 3.1 is installed into your system. Go to Application –> Office –> OpenOffice 3.1 Base and configure you workspace

If you see this message once you run OpenOffice:

OpenOffice.org requires a Java runtime environment (JRE) to perform
this task. THe selected JRE is defective. Please select another
version or install a new JRE and select it under Tools - Options -
OpenOffice.org - Java

you should update your Java JRE: install sun-java6-jre using Synaptic Manager and your are done.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Linux
Actions:   Bookmark and Share | Permalink | Comments (4) | Comment RSSRSS comment feed