2009年7月31日 星期五

Skype for Linux 2.0 pipelogin

#!/bin/sh
echo "user pass" | /usr/bin/skype --pipelogin

===============================
skype --help
Skype 2.0.0.63

Usage: skype [options]
Options:
--dbpath= Specify an alternative path to store Skype data files.
Default: ~/.Skype
--resources= Specify a path where Skype can find its resource files.
Default: /usr/share/skype
--disable-api Disable Skype Public API.
--disable-cleanlooks Disable forced use of the Cleanlooks Qt style.
Use this option together with Qt's -style <%style>
command to set a custom Qt style for Skype.
--pipelogin Command line login. "echo username password | skype --pipelogin"
--version Display version information and exit.

2009年7月9日 星期四

APT使用Proxy

兩種Proxy: HTTP和SOCKS

1. HTTP (natively)

可以通過三種方法為apt-get設置http代理

方法一)

這是一種臨時的手段,如果您僅僅是暫時需要通過http代理使用apt-get,您可以使用這種方式。

在使用apt-get之前,在終端中輸入以下命令(根據您的實際情況替換yourproxyaddress和proxyport)。

export http_proxy=http://username:password@proxyip:port

方法二)

這種方法要用到/etc/apt/檔夾下的apt.conf文件。如果您希望apt-get(而不是其他應用程式)一直使用http代理,您可以使用這種方式。

注意: 某些情況下,系統安裝過程中沒有建立apt配置檔。下面的操作將視情況修改現有的配置檔或者新建配置檔。

sudo gedit /etc/apt/apt.conf

在您的apt.conf檔中加入下面這行(根據你的實際情況替換yourproxyaddress和proxyport)。

Acquire::http::Proxy "http://username:password@proxyip:port";

保存apt.conf文件。

方法三

這種方法會在您的主目錄下的.bashrc文件中添加兩行。如果您希望apt-get和其他應用程式如wget等都使用http代理,您可以使用這種方式。

gedit ~/.bashrc

在您的.bashrc檔末尾添加如下內容(根據你的實際情況替換yourproxyaddress和proxyport)。

http_proxy=http://username:password@proxyip:port
export http_proxy

保存檔案。關閉當前終端,然後打開另一個終端。

使用apt-get update或者任何您想用的網路工具測試代理。我使用firestarter查看活動的網路連接。

如果您為了糾正錯誤而再次修改了配置檔,記得關閉終端並重新打開,否自新的設置不會生效。


2. SOCKS

從sources.conf的man裏面發現,apt只支援http proxy,但是使用ssh代理產生的socks5更方便。那麼只能使用 tsocks來進行socks代理了。

A) 安裝:

apt-get install tsocks


B) 使用前設置conf檔

vi /etc/tsocks.conf

做一個簡單的配置就好了:

local = 192.168.1.0/255.255.255.0 #local表示本地的網路(IP/Subnet),也就是不使用socks代理的網路
local = 127.0.0.0/255.0.0.0
server = 127.0.0.1 #socks伺服器的IP
server_type = 5 #socks服務版本
server_port = 7070 #socks服務使用的埠
default_user = rocky #authentication用的帳號, 僅限SOCKS5
default_pass = 123456 #authentication用的密碼, 僅限SOCKS5

另外還有個 reaches 參數:

reaches

This directive is only valid inside a path block. Its parameter is formed as IP[:startport[-endport]]/Subnet and it specifies a network (and a range of ports on that network) that can be accessed by the SOCKS server specified in this path block. For example, in a path block "reaches = 150.0.0.0:80-1024/255.0.0.0" indicates to tsocks that the SOCKS server specified in the current path block should be used to access any IPs in the range 150.0.0.0 to 150.255.255.255 when the connection request is for ports 80-1024.


要注意的是"server"中的IP必須包含在"local"裏面,否則不能使用,比如使用apt更新的時候會報下面這個錯誤:

0% [Working]20:13:21 libtsocks(11619): SOCKS server xxx.xx.xxx.xxx (xxx.xxx.xxx.xxx) is not on a local subnet!

使用tsocks代理apt-get:

tsocks apt-get update
tsocks aptitude upgrade
...
很簡單,就是在命令前面加上"tsocks"就可以了,tsocks會使用"exec"來運行命令。