Friday, February 26, 2010

tip connect to PC behind firewall

This is a very nice tip on this topic from

Comfortable SSH Access to a Computer Behind a Firewall

Rationale

Sometimes your university takes security serious and firewalls every computer on their intranet, even if you are interested to access it from outside. The following steps enable a comfortable, nearly transparent SSH tunnel to penetrate the firewall. All that is needed is a computer outside with SSH access that can operate as a relay.
The software needed should be already installed on any current unix system: secure shell client/server and netcat (nc).

Server Configuration

Login to the computer behind the firewall.
  1. Generate a new ssh private key that is to be used as the authentication for the tunnel. It will have no password to enable automatic login.
    ssh-keygen -f ~/.ssh/tunnel-id -t rsa -N ""
  2. Create a new entry in your ~/.ssh/config that will be used to initiate the tunnel. Set the Host entry to an uncommon name so that you will also be able to login to the relay computer normally. It will establish a connection from port 11111 on the loopback interface on the relay computer to the ssh port on the loopback interface on the server.
    Host relay
    HostName relay.hostname.com
    RemoteForward 11111 localhost:22
    IdentityFile  ~/.ssh/tunnel-id
  3. Copy the public key to the relay server:
    ssh-copy-id -i .ssh/tunnel-id relay.hostname.com
  4. To make it easy to start the tunnel, create a script in ~/bin/setup-tunnel.sh:
    while true; do 
        /usr/bin/ssh relay
        sleep 1
    done < /dev/null & disown

Relay Configuration

Login to the relay computer.
  1. The ssh-copy-id appended the public key to the ~/.ssh/authorized_keys file. Because we want to limit the havoc that can be caused by the key, change the entry that was just created
    ssh-rsa AAAAB3...= user@server.domain.com
    to
    command="sleep 604800" ssh-rsa AAAAB3...= user@server.domain.com
    This will give the tunnel a livetime of a week, make it work without a local terminal on the server side (we used < /dev/null) and limit the commands that can be executed with this key.

Client Configuration

Login to the client computer.
  1. To make it possible to transparently connect to the server through the tunnel, we use netcat on the relay computer and a ProxyCommand in the ~/.ssh/config file on the client. Add a new entry with
    Host server
    HostName server.hostname.com
    ProxyCommand ssh relay.hostname.com bin/nc localhost 11111

Usage

Whenever you want to have the tunnel enabled, start ~/bin/setup-tunnel.sh on the server. Afterwards you will be able to connect from the client with ssh server. You will be asked for a password two times, once for the relay and once for the server.
The following diagram shows the general idea of the created tunnel:

+--------+       (          )      +----------------------+
| Client |------(  Internet  )---->|  relay.hostname.com  |
+--------+       (          )      +----------------------+
    :                                         /|\          
    :                                          |           
    :                                        [ X ]         
    :                                          |           
    : Forwarded ssh connection      +-------------------+  
    :..............................>| server.domain.com |  
      over "server" ssh alias       +-------------------+  
                                                           
--- real connection                                        
... virtual connection                                     
[X] switch                                                 


Wednesday, February 24, 2010

Collect evolution to MS exchange server 2007 via DavMail


Using DavMail as a bridge, edit account, receive server as 
localhost:1110 etc, works well. It retrieves mails in inbox. 
Some suggests that imap will get new mail from all folders. 
I got a error. Back to pop at the time being.

Davmail can used as bridge for fetchmail too

here is a example of fetchmailrc

poll localhost
 port 1110
        with protocol pop3
        username DOMAIN\user password mypasswd keep is localuser;

Build Evolution from Source Made Simple

 http://mad-scientist.us/evolution.html

Evolution site

 http://projects.gnome.org/evolution/index.shtml

Thursday, February 18, 2010

R installing on Unix/Linux - no root access

R installing on Unix/Linux - no root access

I am luck to get hints from  http://onertipaday.blogspot.com/2008/04/r-installing-on-unixlinux-no-root.html


1. downloaded the tar.gz of the development version of R from
ftp://ftp.stat.math.ethz.ch/Software/R/
2. uncompress it to a directory you have write access to, say ~/R
3. change into the uncompressed directory, eg ~/R/R-2.10.1
4. run "./configure"
5. run "make"
Afterwards you can start R by executing ~/R/R-devel/bin/R;
to simplify that either add the bin directory to your path or create an alias for R
You do not need to run "make install" to work with R.
to install packages,

~/R/R-2.101.1/bin/R CMD INSTALL pkg.gz -l ~/R/R-2.10.1/library/

Wednesday, January 27, 2010

Vi tips & trciks

This starts with my curiousity. I sent a question to fedora list

I come cross a remote server, when I type vim x.pl, it pops up a
default format as below. It is nice. I look through my server,  can't
figure out how to set up the vi parameters. Could some one show me
how?

I am on gnome desktop of F12.


#!/usr/bin/perl
#=============================


#FILE:  x.pl
#USAGE:  ./x.pl

#DESCRIPTION:

#OPTIONS:  ---
#REQUIREMENTS:  ---
#BUGS:  ---
#NOTES:  ---
#AUTHOR:   (), <>
# COMPANY:
#VERSION:  1.0
#CREATED:  01/27/2010 07:55:21 PM CST
#REVISION:  ---
#=============================

use strict;
use warnings;

got hint from a reader http://lonehacks.blogspot.com/. I installed vim-perl-support. It works brightly. Here is an addition link for vi fun vi-vim-tips-and-tricks.

Happy Vi

Tuesday, January 26, 2010

Configure Gtalk/Pidgin behind proxy firewall

How to set proxy for Gtalk on pidgin? 

most connections, web, pidgin etc must go through a proxy. the proxy set as

host proxy.aaa.bbb.cc
port 8080
user username
password passwd

Take Gtalk as my test case, I work on gnome desktop of F12

1. System -> Preferences -> Network Proxy "directly internet connection' checked, that means no global or system environmental proxy setting
2. Pidgin Tools -> Preferences -> Proxy -> Configure Proxy -> 'Direct Internet Connection' checked
3. Pidgin -> Accounts ->Add -> Google Talk
Basic tab
  Protocol: Google Talk
  Username:
  Domain: gmail.com
Advanced tab
  Require SSL/TLS check
  Force old (port 5223) ssl checked

  Connect Port: 443
  Connect Server: talk.google.com
  File transfer proxies: proxy.eu.jabber.org
Proxy tab

set you http proxy
  proxy server:
  port:
  username:
  password:

click Add

You are good to connect