Results tagged “socks”

Raspberry Pi 的环境梳理

1.tsinghua.edu.cn的apt package不完整(安装VIM失败),而且从速度来看,也没优势,用回了原来的库:

$ cat sources.list
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi

2.系统中自带的VIM功能严重不足?从工作开发机拿来的配置基本没法用,所以重新更新安装了VIM
sudo apt-get install vim

3.下载上传不方便,安装了lrzsz
sudo apt-get install lrzsz

4.没有telnet开户端,测试网络端口不方便,需要安装:
sudo apt-get install telnet

5.安装go:
http://dave.cheney.net/2012/09/25/installing-go-on-the-raspberry-pi

Installing the prerequisites
Raspbian comes with almost all the tools you need to compile Go already installed, but to be sure you should install the following packages, described on the golang.org website.

% sudo apt-get install -y mercurial gcc libc6-dev
Cloning the source

% hg clone -u default https://code.google.com/p/go $HOME/go
warning: code.google.com certificate with fingerprint 9f:af:b9:ce:b5:10:97:c0:5d:16:90:11:63:78:fa:2f:37:f4:96:79 not verified (check hostfingerprints or web.cacerts config setting)
destination directory: go
requesting all changes
adding changesets
adding manifests
adding file changes
added 14430 changesets with 52478 changes to 7406 files (+5 heads)
updating to branch default
3520 files updated, 0 files merged, 0 files removed, 0 files unresolved

Building Go
% cd $HOME/go/src
% ./all.bash
If all goes well, after about 90 minutes you should see

ALL TESTS PASSED

---
Installed Go for linux/arm in /home/dfc/go
Installed commands in /home/dfc/go/bin
If there was an error relating to out of memory, or you couldn't configure an appropriate swap device, you can skip the test suite by executing

% cd $HOME/go
% ./make.bash
as an alternative to ./all.bash.

Adding the go command to your path
The go command should be added to your $PATH

% export PATH=$PATH:$HOME/go/bin
% go version
go version devel +cfbcf8176d26 Tue Sep 25 17:06:39 2012 +1000
Now, Go and make something awesome.


但直接更新出问题,该死的墙!需要走代理才行。
strace 进去发现网络死掉,接下载源代码,编译安装失败,看来必须翻了。

6.安装代理软件,最终我使用的是tsocks
sudo apt-get install tsocks
编辑/etc/tsosks.conf即可。
另外的privoxy安装了但没使用。

参考:
http://blog.creke.net/770.html
http://blog.ihipop.info/2011/01/1988.html
在终端下间接使用Socks5代理的几种方法(privoxy,tsocks,proxychains)

http://www.privoxy.org/
http://tsocks.sourceforge.net/faq.php

http://renyongjie668.blog.163.com/blog/static/16005312011824112410588/
http://www.51testing.com/?uid-225738-action-viewspace-itemid-246084

使用tsocks:
tsocks [application [applications arguments]]
tsocks [on|off]

举几个实例吧:
tsocks firefox  #之后再firefox上浏览网页就会默认使用tsocks配置的代理
tsocks git clone git://github.com/avikivity/kvm.git #使用proxy来git,这就是我用的原因

source tsocks on #设置当前shell的tsocks,该命令可能遇到一个小bug在下面有讲到
tsocks show    #查看当前Shell的tsocks设置,tsocks: This shell is socksified.
do_something   #这里就能默认使用tsocks的代理去do something了,前面已经设置了
source tsocks off #关闭当前shell的tsocks代理设置
tsocks show    #再次查看,tsocks: This shell is NOT socksified.
遇到的问题及解决方案:

13:01:17 libtsocks(2432): SOCKS server proxy-shz.intel.com (10.239.120.36) is not on a local subnet!
设置的代理没有与/etc/tsocks.conf文件中的local设置的网络在同一个子网中。
13:03:26 libtsocks(2451): The SOCKS server (proxy.ABCD.com) listed in the configuration file which needs to be used for this connection is invalid
配置文件的问题,我也忘了是啥时出现的错误了,但我碰到过的。
13:02:50 libtsocks(2441): Error 110 attempting to connect to SOCKS server (Connection timed out)
这个很明显了,就是你设置的proxy连接不上(可能是本来就连不上,或者没在同一个局域网内),请检查和确认配置。

ERROR: ld.so: object '/lib64/libtsocks.so' from LD_PRELOAD cannot be preloaded: ignored.
郁闷坏了,是因为有一次我在rhel5u5上安装了一个rhel6的tsock rpm包,解决办法是到http://pkgs.org/找到一个tsocks for rhel5的rpm包,安装即可。

[root@kvm-build ~]# source /usr/bin/tsocks on
basename: invalid option -- 'b'
Try `basename --help' for more information.
看到这样的错误,有可能是你的tsocks有点小bug,不过不影响使用的,接着你用tsocks show来看,一样可以看到提示说socks设置成功的,tsocks: This shell is socksified.

我的rhel5和rhel6中的tsocks都遇到这样的错误信息,你可以简单地修改一下/usr/bin/tsocks文件,将其中的basename的一行修改一下即可:

修改前:PRG="$(basename $0)"
修改为:PRG="$(basename -- $0)"

这是由于这个tsocks写后,coreutils工具做了些改动,其中basename工具需要用"--"来表示options的结束(为了保持新老版本的兼容)。这个问题在Bug-coreutils mailing list中讨论过了的,见:http://www.mail-archive.com/bug-coreutils@gnu.org/msg09912.html

替代工具机参考文档:
一个与tsocks有类似功能的工具: socat   (我暂时没怎么用)
见:http://freshmeat.net/projects/socat/
tsocks.conf配置文件:http://linux.die.net/man/5/tsocks.conf
tsocks的使用:http://www.21andy.com/blog/20100212/1678.html 
另外的人遇到的tsocks问题:http://notes.benv.junerules.com/socks-opera-and-brute-force/




--EOF--

奇怪的Proxifier和SocksCap32

最近重新想折腾一下通过代理来进行办公环境的整合:
1)笔记本通过台式机做一级代理访问内部网站
2)笔记本通过台式机一级代理和二级代理访问大部分外部网站
3)笔记本直接通过TD的3G给某些程序上网

使用Proxifier和sockscap32来进行,其实如果Proxifer的代理规则更优化一下,针对不同的程序使用不同的Proxy Chain,那只需要使用Proxifer就应该可以搞定了,可惜不支持。另外ProxyCap和WildeCap均和Proxifer有冲突,无法共存,而和SocksCap32则相安无事,所有就只能用这2个来玩了。

1)在本机建好2个socks5代理,分别是2080和3080端口,2080供Proxy Chain的一级代理给Proxifer使用,3080供SocksCap32访问内部网站用。

2)先停掉Proxifier,开始在SocksCap中加入TT和Outlook,TT专门访问内网网站,Outlook用来收内部邮件,TT正常使用,而Outlook却无法正常使用,怪哉!然后启动Proxifer,特意将Outlook排除在使用代理的程序之外,仍然无效,悲剧之极,很是伤心。

今天调整Proxifer的策略时,通过SocksCap32开启了Outlook,居然发现登录正常,而且还通过了Proxifer的代理,这下彻底不明白了。于是在Proxifer中加入了Outlook也走代理的规则,问题解决。

但是:
如果是通过Sockscap32走的代理,为啥独立访问不行呢?
如果是通过Proxifer走的代理,按道理应该是走的Proxy Chain,按道理应该也是无法访问的。
使用TT则一切仍然是预想中的通道,访问内网,只通过SocksCap32,不通过Proxifer。

看来有必要了解一下这2个代理的机制了,不冲突本身已经很值得研究一下了。

--EOF--

今天想玩2个不同的代理软件,走2个不同的代理,可惜Proxifier不支持,就重新试了试widecap。
一个星期前装过一次,安装后很多程序出现异常,无法运行,上网也有问题,遂卸载,最后还重新安装了Proxifier才搞好。
今天再次安装,当然也是不行,但杯具的还在后面,使用了360来卸载widecap,不知道干掉了啥东西,Proxifier重新安装多次也没用,
2.8/2.9的版本都测试了,很多程序无法走代理。测试的时候偶然发现portable2.8版本的却又是正常的,但安装版就是不行。
无奈之下重新安装了一次widecap,再正常卸载,再安装Proxifier,这下才算搞好正常了。

小结:再也不要用widecap这个垃圾软件了,特别是如果你使用windows7的话。

--EOF--

因为dd-wrt自带的ssh(dropbear提供)功能不完整,因此想安装openssh-client,前提是支持Jffs或者USB等。

我的WRT54GS v1.1 有8M的ROM,之前刷的是标准版,jffs功能是不支持的,因此需要重新刷ROM。

下载的ROM是dd-wrt.v24-13064_VINT_openvpn_jffs_small.bin,使用之前的升级办法通过ssh上去操作,总是失败,无法正确升级,后来一怒之下通过web来刷,成功了~

刷好后就是安装相关pkg了:

ipkg install openssh-client

root@DD-WRT:/jffs/tmp/ipkg# ipkg install openssh-client

Downloading http://downloads.openwrt.org/whiterussian/packages/libopenssl_0.9.8d-1_mipsel.ipk ...
Connecting to downloads.openwrt.org (78.24.191.177:80)
Done.
Unpacking libopenssl...Done.
Configuring libopenssl...Done.

Downloading http://downloads.openwrt.org/whiterussian/packages/zlib_1.2.2-2_mipsel.ipk ...
Connecting to downloads.openwrt.org (78.24.191.177:80)
Done.
Unpacking zlib...Done.
Configuring zlib...Done.

Downloading http://downloads.openwrt.org/whiterussian/packages/openssh-client_4.4p1-1_mipsel.ipk ...
Connecting to downloads.openwrt.org (78.24.191.177:80)
Done.
ipkg_install_file: ERROR: openssh-client depends on the following uninstalled programs:
         libopenssl zlib
ipkg_install_file: You may want to use `ipkg install' to install these.
ipkg_get_install: ERROR: Failed to install /jffs/tmp/ipkg/openssh-client_4.4p1-1_mipsel.ipk
ipkg_get_install: I'll leave it there for you to try a manual installatio

虽然自动安装了相关依赖,但后面确实失败,手工下载后然后再安装:
ipkg -force-depends install openssh-client_4.4p1-1_mipsel.ipk

注意参数 -force-depends 的位置,安装成功。

/jffs/usr/bin/ssh -NfT -D 192.168.1.1:1080 root@192.168.1.1   --    通过本地的ssh服务做代理 
/jffs/usr/bin/ssh -NfT -D 192.168.1.1:1080 xxxx@remotehost    --   通过远程服务器做代理

其实我想的是直接由路由器提供socks代理,不止是给局域网内的其它机器。


第一种实际就是想把路由器作为一个socks服务器,不需要client再通过putty等程序进行设置。
第二种当然也是做代理,而且是透明的使用远程的服务器做ssh代理。

不过实际测试的时候,虽然设置了端口转发,但从WAN口来的请求总是无法连接,这个会是啥原因?有些奇怪。





--EOF--

没用上无限卡之前,都是通过家里的路由器提供的ssh访问做代理来玩的,自动上了无限卡,好久没在公司使用家里路由器的ssh服务了。由于公司也有网络限制,因此之前家里路由器开放的端口是80,今天在家无聊想试试无限卡的访问情况,居然发现80端口无法连上,其它几个端口8080 8000 443 23等都还是正常的,无语了。

现在路由器DD-WRT的一些配置:
ssh管理启用:默认端口是22
开放远程ssh访问,端口设置为22(之前是80);
禁止telent协议访问;
置部分端口转发:8000/443/8080/80 -> 22
开放http远程访问,端口80;

效果:
80端口还是访问的http服务,非ssh服务。


--EOF--

FastDomain后续的使用想法:Dedicated IP

和FastDomain的多个客服线上确认,即使购买了Dedicated IP,也无法更改SSHD的访问端口,而对于我来说,这个东西实际上还是很重要的。

但经过前几天的一些探索,有了另外一个想法,直接使用ssh提供的Port Forward功能或许可以达到类似的效果,前提当然是能让我绑定很多其它端口了:)

 

https://www.fastdomain.com/cgi/dedicated_ip

 

What is a Dedicated IP Address?
An IP address is a number like 234.123.66.7 that identifies the unique server where your website can be found. In shared hosting, you share the same IP address as other web sites on your server. By upgrading to a Dedicated IP address, you can enable your site for e-commerce and other advanced capabilities, and minimize the risk of being impacted by other sites on your shared server.


Top Reasons to get a Dedicated IP:
So you can enable SSL on your web site - SSL Certificates are crucial if you have a business oriented website, especially if you want to accept secure transactions like credit card payments or sending personal information through your site. Secure SSL Certificates require your site to have a Dedicated IP in order to work.
Ability to run more software on your server - Certain programs require a dedicated IP address before they can be setup and used. With a dedicated IP you will have more options on the type of scripts you can run.
Ability to open non-standard ports - Purchasing a dedicated IP will allow us to grant you access to additional ports you may need to run special services on that are blocked for shared IPs.
So you won't be negatively impacted by the actions of others - On a shared IP, if someone else sharing your same IP happens to get blocked by IP or censored, as some countries or ISPs sometimes do. Their IP (and yours) could get banned or blacklisted, causing problems for your web site or search engine rankings.
Your website may perform better in the search engines - Although difficult to prove, many people believe that sites with a dedicated IP address rank better in the search engine results than those utilizing shared IP addresses.
You can view your web site by typing its IP address - This is handy for situations where you want to access your site, but your domain name is inaccessible, such as during domain name propagation periods.

Only $2.50 per month ($30.00 per year)*

--EOF--

SSH And Port Forwarding

SSH

zz From http://zhigang.org/wiki/SSH


目录

通过ssh建立安全隧道(ssh tunnelling,也称端口映射,Port Forwarding)
本地映射(Local Forward)
远程映射(Remote Forward)
公钥认证
配置ssh使用代理服务器,穿越企业防火墙
加快SSH连接速度方法
使用expect实现ssh自动交互
SSH保持连接(KeepAlive)
参考资料
本章记录了自己在使用SSH的过程中遇到的一些问题,及其解决方法。


通过ssh建立安全隧道(ssh tunnelling,也称端口映射,Port Forwarding)
通过ssh的端口映射功能可以方便地存取一下无法直接访问的资源。又分为本地映射(Local Forward)和远程映射(Remote Forward)。


本地映射(Local Forward)

$ ssh -f -g -A -X -N -T -L 1234:remote-host2:5678 user@remote-host或者通过修改ssh的配置文件:

$ cat ~/.ssh/config
Host remote-host
     Hostname x.x.x.x (your remote host IP)
     LocalForward 1234:remote-host2:5678
     User user
$ ssh user@remote-host所有对本地1234端口的访问都通过remote-host被转发到remote-host2的5678端口。有些DMZ中只开放sshd的22端口,通过本地映射,你可以访问远程计算机上的所有服务。


远程映射(Remote Forward)

$ ssh -f -g -A -X -N -T -R 1234:remote-host2:5678 user@remote-host或者通过修改ssh的配置文件:

$ cat ~/.ssh/config
Host remote-host
     Hostname x.x.x.x (your remote host IP)
     RemoteForward 1234:remote-host2:5678
     User user
$ ssh user@remote-host所有对remote-host的1234端口的访问都通过本机被转发到remote-host2的5678端口。通过远程映射,你可以通过家中的机子(有公网IP,可以ssh登录)来访问公司防火墙内部的计算机。


公钥认证
使用公钥认证经常遇到的问题就是一些文件的权限问题。一些问题可以通过查看/var/log/secure来发现。

要配置两台计算机使用公钥认证,可以通过分别在两台机子host1、host2上运行如下脚本:

$ ssh-keygen -t rsa -b 1024 # don't input any password
$ ssh $host1 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ ssh $host2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys # important!
配置ssh使用代理服务器,穿越企业防火墙
通过 http://zippo.taiyo.co.jp/~gotoh/ssh/connect.html 下载connect.c,编译,拷贝到系统/usr/bin目录:

$ gcc connect.c -o connect
$ sudo cp connect /usr/bin编辑ssh的配置文件~/.ssh/config,增加:

$ cat ~/.ssh/config
Host remote-host
     ProxyCommand connect -H your.proxy.com:port %h %p
$ ssh user@remote-host
加快SSH连接速度方法
SSH登录时会进行DNS反查,如果你的DNS Server速度比较慢,会发生等待。知道了原因解决方法就出来了:就是提高域名解析的速度。可以将主机名写到/etc/hosts中来解决。


使用expect实现ssh自动交互
下面是使用expect实现的自动远端命令执行的脚本remote-exec:

# \
exec expect -- "$0" ${1+"$@"}
# remote-exec - execute command on remote host
# Version 0.1
# Zhigang Wang <zhigang.x.wang@oracle.com>
exp_version -exit 5.0

if {$argc!=2} {
    send_user "usage: remote-exec command password\n"
    send_user "Eg. remote-exec \"ssh user@host ls\\; echo done\" password\n"
    send_user "or: remote-exec \"scp /local-file user@host:/remote-file\" password\n"
    send_user "or: remote-exec \"scp user@host:/remote-file local-file\" password\n"
    send_user "or: remote-exec \"rsync --rsh=ssh /local-file user@host:/remote-file\" password\n"
    send_user "Caution: command should be quoted.\n"
    exit
}

set cmd [lindex $argv 0]
set password [lindex $argv 1]

eval spawn $cmd

set timeout 120

while {1} {
    expect -re "Are you sure you want to continue connecting (yes/no)?" {
            # First connect, no public key in ~/.ssh/known_hosts
            send "yes\r"
        } -re "assword:" {
            # Already has public key in ~/.ssh/known_hosts
            send "$password\r"
        } -re "Permission denied, please try again." {
            # Password not correct
            exit
        } -re "kB/s|MB/s" {
            # User equivalence already established, no password is necessary
            set timeout -1
        } -re "file list ..." {
            # rsync started
            set timeout -1
        } -re "bind: Address already in use" {
            # For local or remote port forwarding
            set timeout -1
        } -re "Is a directory|No such file or directory" {
            exit
        } -re "Connection refused" {
            exit
        } timeout {
            exit
        } eof {
            exit
        }
}
SSH保持连接(KeepAlive)
可以使用下面的方法:

增加下面的内容到~/.ssh/config或者/etc/ssh/ssh_config:

Host *
  ServerAliveInterval 60 # in second执行下面的脚本:

while date; do sleep 10; done当要输入命令时,只需要按下ctrl-c.


参考资料
OpenSSH official site.

OpenSSH Manual Pages.

The Secure Shell(tm) Frequently Asked Questions.

SSH Tunnelling (Port Forwarding).

SSH Port Forwarding.

SSH Proxy Command -- connect.c.

Corkscrew -- tool for tunneling SSH through HTTP proxies.

SSH Host Key Protection.

SSH and ssh-agent.

The Expect Home Page.

Pexpect - a Pure Python Expect-like module.

 

--EOF--

ssh server dropbear 测试失败

dropbear -w -F -E -p 8000 -P /home/xxx/sshd/dropbear_sshd.pid  -d /home/xxx/sshd/dropbear_dss_host_key -r /home/xxx/sshd/dropbear_rsa_host_key

 

dropbearkey -t rsa -f dropbear_rsa_host_key -s 1024
dropbearkey -t dss -f dropbear_dss_host_key -s 1024


ssh xxx@127.0.0.1 -p 8000
chsh --list-shells
chsh -s /bin/sh yimutian

 

$ chsh -s /bin/sh xxx
Changing shell for xx.
Password:


[25376] Dec 19 05:56:32 Child connection from ::ffff:127.0.0.1:58456
[25376] Dec 19 05:56:38 user 'xxx' has invalid shell, rejected

 

From FastDomain Support:

1.Can't Change Login Shell

2.Can't Change sshd port

3.What Can I Do ?

--EOF--

编译安装测试socks proxy 和 ssh server

编译安装:

socks proxy:

ss5

antinat-0.90  依赖 expat-2.0.1

ssh server:

dropbear-0.52

lsh-2.0 依赖 liboop-1.0

 

注意使用编译选项:

./configure CPPFLAGS="-I/path/to/expat/include" LDFLAGS="-L/path/to/expat/lib" --prefix=xxx

--EOF--

Comparison of SSH servers

zz From http://en.wikipedia.org/wiki/Comparison_of_SSH_servers

Comparison of SSH servers

From Wikipedia, the free encyclopedia

Jump to: navigation, search

SSH servers is a software program which uses the secure shell protocol to accept connections from remote computers. This article compares a selection of popular servers.

Contents

[hide]

[edit] General

Name  ↓ Developer  ↓ Status  ↓ Date of first release  ↓ Last release  ↓ Date of last release  ↓ License  ↓ Official web page  ↓
CopSSH Itefix Active 2009-01-16 3.0.1 2009-10-12 BSD CopSSH
Dropbear Matt Johnston Active 2003-04-06 [1] 0.52 2008-11-12 MIT Dropbear
F-Secure SSH Server F-Secure  ? 2004? commercial
freeSSHD Kresimir Petri  ? 1.2.6 2009-??-??  ? [1]
KpyM KpyM Active 1.18 2009-08-01 [2] BSD [2]
lsh Niels Möller Active 1999-05-23 [3] 2.9-exp 2007-04-04 GPL LSH
OpenSSH The OpenBSD project Active 1999-12-01 5.3 2009-10-01[4] BSD OpenSSH
Reflection for Secure IT Attachmate Active 7.1 commercial [3]
Tectia SSH Communications Security Active 1995 6.1 commercial SSH Communications Security
VShell server VanDyke Software, Inc. Active 1995 3.6 2009-12-10 commercial VanDyke VShell

[edit] Platform

The operating systems or virtual machines the SSH servers are designed to run on without emulation; there are several possibilities:

  • No indicates that it does not exist or was never released.
  • Partial indicates that while it works, the server lacks important functionality compared to versions for other OSs but may still be under development.
  • Beta indicates that while a version is fully functional and has been released, it is still in development (e.g. for stability).
  • Yes indicates that it has been officially released in a fully functional, stable version.
  • Dropped indicates that while the server works, new versions are no longer being released for the indicated OS; the number in parentheses is the last known stable version which was officially released for that OS.
  • Included indicates that the server comes pre-packaged with or has been integrated into the operating system.

The list is not exhaustive, but rather reflects the most common platforms today.

Name  ↓ Mac OS X  ↓ Mac OS Classic  ↓ Windows  ↓ Cygwin  ↓ BSD  ↓ Linux  ↓ Solaris  ↓ Palm OS  ↓ Java  ↓ OpenVMS  ↓ Windows Mobile  ↓ IBM z/OS  ↓ AmigaOS  ↓ AIX  ↓ HPUX  ↓ iPhone / iPod Touch  ↓ WebOS  ↓
CopSSH No No Yes Yes No No No No No No No No No No No No No
Dropbear Yes No No Yes Yes Yes Yes No No No No No No No No No Yes
lsh Yes No No No Partial Yes Yes No No No No No No No No No No
OpenSSH included No Yes included included included Yes No No Yes No Yes Yes Yes Yes Yes Yes
KpyM No No Yes No No No No No No No No No No No No No No
freesshd No No Yes No No No No No No No No No No No No No No
  • ^  lsh supports only one BSD platform officially, FreeBSD.[citation needed]
  • ^  The majority of Linux distributions have OpenSSH as an official package, but a few do not.
  • ^  Openssh 3.4 was the first release included since AIX[citation needed]
  • ^  Unless otherwise noted, iPhone refers to non-jailbroken devices.
  • ^  [4]
  • ^  Only for jailbroken devices.
  • ^  OpenSSH and Dropbear are available as optware packages installed by PreWare (maintained by WebOS-Internals.org)

[edit] Features

Name  ↓ SSH1  ↓ SSH2  ↓ Port forwarding  ↓ SFTP  ↓ SCP  ↓ Compatible with OpenSSH authorized keys  ↓ Privilege separation  ↓
CopSSH Yes Yes Yes Yes Yes Yes Yes[5]
Dropbear (software) No Yes Yes No No[6] Yes  ??
Lsh No Yes Yes Yes Yes  ??  ??
OpenSSH Yes Yes Yes Yes Yes Yes Yes[7]

[edit] See also

[edit] References

--EOF--

2  

Pages

March 2025

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31