[How-To]Ubuntu apt-get behind ISA Server with NT Authenticfation required

在公司里面,网络访问都是通过ISA Server的(Microsoft® Internet Security and Acceleration Server),在使用Windows的时候不会出现任何问题,可是前两天装了Ubuntu Linux,遇到了些问题。

我使用firefox访问网络没有问题,只需要设好代理服务器地址,浏览网站时输入相应的用户名和密码即可,但在console下面使用apt-get更新系统时有问题。

开始我觉得应该这样设置代理:
export http_proxy=http://domaindomainuser:password@proxy.corpnet.com:8080

可是总会出现这个错误:
407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. )

后来在网上搜索了一下,找到方法解决这个问题了:

Download ntlmaps-0.9.9.0.1 from here

$ tar -zxvf ntlmaps-0.9.9.0.1

$ vim ntlmaps-0.9.9.0.1/server.cfg

Edit PARENT_PROXY,PARENT_PROXY_PORT,USER,PASSWORD to match your preferences, then run main.py

$ ./ntlmaps-0.9.9.0.1/main.py &

$ export http_proxy=”http://127.0.0.1:5865

$ sudo apt-get update

Now, everything is OK.

reference: http://www.lupaworld.com/912/viewspace_2210.html

在 Rails 之外使用 ActiveRecord

原文链接已经被墙:http://lightyror.thegiive.net/2007/03/rails-activerecord_15.html

今天要写一个cron script 要用到数据库,因为已经被Active Record 惯坏了,懒得用SQL。所以就花点时间Survey 怎么再Rails 之外使用Active Record


简单版

1. require
相关的lib

require “rubygems”
require “active_record”

2.
建立DB Connection

ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:username => “root”,
:host => “localhost”,
:password => “secret”,
:database => “plants_db”
)

3.
宣告ActiveRecord Class

class MyClass < ActiveRecord::Base
end


如此就可以开始使用啦。不过如果遇到你必须一次操作多个DB 的情况时,你可以用比较Rails 一点的Config 来写作

加入Config 的用法

1. require
相关的lib

require “rubygems”
require “active_record”

2.
撰写DB 配置文件,我们仿Rails 写一个database.yml

development:
__adapter: mysql<
br/>__host: localhost
__username: root
__password:
__database: lala



3.
将配置文件读进来,读到一个$config 变数

$config = YAML.load_file(File.join(File.dirname(__FILE__), ‘database.yml’))

4.
宣告ActiveRecord 对象,记得加上establish_connection

class MyClass < ActiveRecord::Base
establish_connection $config[''development"]
end


5.
开始快快乐乐使用ActiveRecord

Problem of starting a manually created postgres server in Ubuntu

You could chown the directory /var/run/postgresql/ to the user postgres is
running as. You might need root access for that as well, in case you dont
have it you could ask your sysadmin to do it.

Regards,
Patrick Lindeman

> I’m trying to start my postgres server and it gives me the following
> errror
>
> FATAL: could not create lock file
> “/var/run/postgresql/.s.PGSQL.5432.lock”:
> Permission denied
>
> Now obviously to touch the file that the error message is talking about,
> one
> needs root permission that the user account under which my postmaster is
> runnnig doesn’t have.
>
> Can anyone tell me the fix.
>
> Thanks
>

Powered by ScribeFire.

Ubuntu 7.10/8.04 字体美化的最简便方法(中文雅黑;英文苹果)

1。下载字体
下载地址:http://www.box.net/shared/lvh50qodvn

2。将字体cp到~/.fonts 或者 /usr/local/share/fonts/ 或者 /usr/share/fonts/
其实放在~/.fonts是最简单的方法。
然后终端执行:
sudo fc-cache -f

3。下载配置文件,将下面的文件下载并解压,将其中的文件都复制到/etc/fonts/下
下载地址:http://www.zflier.com/upload/ubuntu-font-optimize.zip

4。调整字体选项。
系统–》首选项–》字体:
除了等宽字体外全部选择Lucida Grande
字体渲染选择次像素平滑!(这一步是设置应文字体)

5。按ctrl+alt+backspace重启x server,并登录。

此方法在ubuntu 7.10/8.04试用通过,见下图

在 Windows XP 使用 Cygwin 建置 sshd

目的: 讓 Windows 成為 sshd server, 作為 ssh tunnel 運用

  • 在 Cygwin 設置 sshd service
    • 變更 sshd 埠號
    • 建立 ssh 認證金鑰免密碼登入
  • 在 Cygwin 設置 squid proxy server
    • 修正 Too many open files 問題
    • 以系統服務方式啟動 squid
  • 讓 Cygwin 顯示中文

安裝 Cygwin

http://www.cygwin.com/ 下載並安裝 Cygwin 於 c:\cygwin

  • 建立 c:\cygwin 目錄
  • 將 setup.exe 置入 c:\cygwin
  • 執行 setup.exe
  • Choose A Download Source → Install from Internet
  • Select Root Install Directory → c:\cygwin
    Install For → All Users
    Default Text File Type → Unix / binary
  • Select Local Package Directory → Local Package Directory: c:\cygwin
  • Select Your Internet Connection → Direct Connection
  • Choose A Download Site → ftp://ftp.nctu.edu.tw 或 ftp://ftp.ntu.edu.tw

本篇所使用的 Package:

  • Admin → cygrunsrv
  • Net → openssh
  • Web → squid

設置 sshd service

啟用 sshd

ssh-host-config

Should privilege separation be used? (yes/no) no
Do you want to install sshd as service? (yes/no) yes
CYGWIN= (直接按 Enter 鍵接受預設值 "ntsec")

cygrunsrv –start sshd 啟動 sshd 服務

將 sshd 預設 tcp 22 port 變更成其他埠號的方法

cd /etc
notepad sshd_config → 將 Port 22 改成 Port 80
cygrunsrv –stop sshd && cygrunsrv –start sshd 重新啟動 sshd service

若 /etc/sshd_config 的 owner 是 system, 須先變更 owner: chown $USER sshd_config 才能編輯 sshd_config. 修改完後記得將 owner 回復為 system: chown system sshd_config, 最後再重新啟動 sshd service 即可

調整 Windows 防火牆設定

控制台 → Windows 防火牆 → 例外 → 新增連接埠

名稱: cygwin-sshd (或其他自己喜歡的名稱), 連接埠編號: 22 (TCP) (若已改成 80 port, 就填入 80)

如要限制連入 sshd 的來源 IP, 可另外加裝 tcp_wrappers package (在 Net 類別裡)

以 ssh 認證金鑰進行連線

適用情況:

  1. 連線時不想輸入密碼
  2. 安裝 Cygwin 的那台電腦, Windows 帳號沒有密碼

ssh-keygen -t rsa 過程皆按 Enter (ssh-user-config 亦可建立金鑰)
cd ~/.ssh
mv id_rsa.pub authorized_keys 將 public key 更名為 authorized_key

將 id_rsa (private key) 複製到想以 ssh 連入 Cygwin 的電腦 (client), 使用 puttygen.exe 將 id_rsa 轉成 PuTTY Private Key File:

  • 執行 puttygen.exe
  • 點選 File → Load private key (剛剛的 id_rsa 檔案)
  • 載入後點選 Save private key, 另存成副檔名為 .ppk 的檔案

Client 使用 PuTTY, 以 ssh protocol 連入 Cygwin sshd 時, 點選 Connection → SSH → Auth → Private key file for authentication: Browser 載入剛剛存好的 .ppk 檔, 再進行 ssh 連線, 輸入帳號後即可登入.

也就是說, Cygwin + sshd 這台電腦 (server), 保留 public key 在 $HOME/.ssh/authorized_key
其他想使用 PuTTY 以 ssh 連入 Cygwin + sshd 的電腦 (client), 連線時載入 .ppk (private key) 檔案

為 Cygwin 帳號設置密碼

passwd

  • 效用等同在控制台設定 Windows 使用者密碼
  • 密碼設置後, 下次開機進入 Windows 時, 系統會詢問密碼
  • 若想開機直接登入桌面, 請參考: 關於 Windows XP 的三個備忘
  • 若已完成直接登入的設置, 但又變更密碼時的處理:
    1. 密碼變更後, 立即執行 control userpasswords2 (Win 2000 沒有最後的 "2")
    2. 先勾選「必須輸入使用者名稱和密碼,才能使用這台電腦」
    3. 再點選預設登入帳號
    4. 最後再取消勾選「必須輸入使用者名稱和密碼,才能使用這台電腦」
    5. 按「確定」後, 系統就會再詢問一次密碼, 此時輸入剛剛變更的密碼即可

转载自http://cha.homeip.net/blog/archives/2006/04/_winxp_cygwin_s.html

Oversea web hostings become popular in China

More and more Chinese bloggers are seeking for reliable oversea web hosting services nowadays.

I believe Godaddy, Dreamhost, Site5, BlueHost, HostMoster and other well-known providers are very happy these days. the mentioned hosting service providers are well known among chinese bloggers. Some of them even have chinese support team now. How bigger the chinese market is!!!

Why do Chinese bloggers become more and more interested in oversea web hostings? You may google "Internet censorship and regulation in China" to find the answer.

Chinese bloggers prefer the hosting packages with the following specials.
1.Dedicated IP.  If a site shares the hosting server’s IP, it is in a real danger. if the server hosting another site that contains information that violate the Chinese law, the server’s IP may be  blocked by the Chinese Internet censorship system(Well-known as "the Greate Fire Wall"). as a result of the censorship technology, Chinese people will never be able to visit that server directly any more. So, a dedicated IP will keep your site safer.
2.SSH. if the package support SSH, Chinese bloggers may use these hosting account as a secret and safe proxy to visit blocked oversea web sites, like wikipedia, technorati and many other very useful sites.

I’ve been using oversea web hostings for over three years. the first provider I used is Pair.com, which is very stable but with a high fee that I can’t afford. I move my sites to DreamHost after my experience with Pair.com. Now, I’m using Godaddy as my hosting provider. The price of Godaddy is low, and the service is good. You can find many coupon code/promotion code on the Internet. Just google "Godaddy coupon code" to find more.

[ANN]Info3G重新开放

Info3G.net重新开放,前一阵子由于主机空间问题,再加上备案风波,Info3G关闭了一段时间,现Info3G.net已找到一稳定空间,希望可以继续提供给大家可靠、稳定的Portable News。
Info3G.net提供基于手机和PDA的新闻信息,目前已收录70多家媒体的即时信息。

mplayer on breezy

mplayer 编译指南

一 安装编译环境:

$ sudo apt-get install manpages-dev
$ sudo apt-get install autoconf
$ sudo apt-get install automake
$ sudo apt-get install libtool
$ sudo apt-get install flex
$ sudo apt-get install bison
$ sudo apt-get install gcc-doc
$ sudo apt-get install g++
$ sudo apt-get install x-window-system-dev
$ sudo apt-get install libgtk1.2-dev
$ sudo apt-get install libpng-dev

二 建立安装目录:

$ mkdir /usr/local/bin/mplayer_install
$ cd /usr/local/bin/mplayer_install

三 下载最新的源代码:

$ wget http://www1.mplayerhq.hu/MPlayer/releases/MPlayer-1.0pre7try2.tar.bz2
$ wget http://www1.mplayerhq.hu/MPlayer/releases/codecs/essential-20050412.tar.bz2
$ wget http://www1.mplayerhq.hu/MPlayer/Skin/Blue-1.4.tar.bz2

四 解压缩源代码,编译并安装:

$ tar -xjf essential-20050412.tar.bz2
$ sudo mkdir -p /usr/local/lib/codecs
$ sudo cp essential-20050412/* /usr/local/lib/codecs/
$ tar -xjf MPlayer-1.0pre7try2.tar.bz2
$ cd MPlayer-1.0pre7try2
$ ./configure –enable-gui
$ make
$ sudo make install
$ tar -xjf Blue-1.4.tar.bz2
$ sudo mkdir -p /usr/local/share/mplayer/Skin/default
$ sudo cp -r Blue/* /usr/local/share/mplayer/Skin/default/
$ sudo cp MPlayer-1.0pre7try2/etc/* /usr/local/etc/mplayer/

五 建立默认的配置文件:

$ vim ~/.mplayer/config

文件内容如下:

## Audio drivers
## Ubuntu uses esd by default.
## These are only mentioned for the sake of completion.

ao=esd
#ao=oss
#ao=alsa
#ao=arts

######

现在就可以使用 mplayer ime_na_file.avi -sub subtitri.srt 来播放了。

How to use apt-get behind proxy server (Ubuntu/Debian)

If you are a Debian-based GNU/Linux user, then you’re probably familiar
with synaptic and apt-get to install application from software
repositories. This post focussed on how to use apt-get/synaptic behind
proxy server/firewall which under normal circumstances, you’re unable to
use apt-get.

If you’re using Synaptic

Open up your Synaptic package manager (usually as root), go to
Settings-> Preference -> Network. Enter your proxy server details
like : username:password@proxyserver.net, and put the proxy server port
(usually 8080).

If you’re using command-line apt-get

Edit your /etc/bash.bashrc file as root.

Put these line at the end of your /etc/bash.bashrc file :

export http_proxy=http://username:password@proxyserver.net:port/
export ftp_proxy=http://username:password@proxyserver.netport/

You can omit the username:password, if your proxy server has no
password. That’s all for today! Happy apt-get-ing!