Really simple SSH proxy (SOCKS5)

原文:

https://thomashunter.name/blog/really-simple-ssh-proxy-socks5/

SOCKS5 is a simple, eloquent method for getting yourself a proxified connection to the internet. All you need to get a proxy connection working is to run an SSH server somewhere, run a single command locally, and configure your software (or OS) to use this proxy. Why would you want to run a proxy? Well, all traffic sent between your client machine (e.g. a wireless laptop at a coffee shop), and the remote machine (e.g. your home server located on your trusted network) will be encrypted. Also, your external IP address will be that of the SSH server, which can be useful for various other reasons.

For this tutorial I will show screenshots for setting up an OS level proxy in OS X. Linux should have some similar GUI tools involved, or you can always configure it on the command line. I’m not sure if Windows has similar tools. I’m assuming you are familiar with networking basics and have a linux server setup with internet connectivity.

The first thing you will need to do is install an SSH daemon on your Linux server. Depending on your OS, it is usually as simple as running the following command (most distro’s allow all normal users SSH access by default, save for the root user).

sudo apt-get install sshd

You’ll also need to have port forwarding setup for the SSH port (22) so that external requests to this port are forwarded to your server. I can’t show you how to do that though since I don’t know how your router works!

Next, you’ll need to run the following command on your client machine. What the command does it executes SSH as a background process, and sets up port 1080 to listen locally for connection requests (you can change that number). It also doesn’t display errors if there are any (useful for running automatically when you login to your client). It will prompt you for a username and password though… What you should do is setup your client and server to authenticate without a password, this will make your life a lot easier and allow the command to be executed without your intervention.

ssh -D 1080 -f -C -q -N -p 22 [email protected]

Easy, huh? You can now configure software to connect to a SOCKS5 proxy at localhost:1080. If you browse toip.thomashunter.name both before and after running this, you should see that your external IP address will change.

You may be wondering how to do that last part… I’ll now show you a bunch of screenshots for enabling this on the OS level using Apple OS X’s network manager.

OS X: Enabling SOCKS5 Proxy

First, open up OS X’s system preferences. You can usually do this by hitting Cmd + Space, and typing Preferences and pressing enter.

OS X System Preferences

Next, click the Network icon under Internet & Wireless. You will see a bunch of tabs, click the one titled Proxies.

Network Proxy Settings in OS X

Now, enable the SOCKS5 Proxy option. This will bring up the configuration settings to the right. You’ll want to enter localhost for the server name and 1080 for the port number. You won’t need to use a username or password with this proxy so leave them blank (the authentication happened earlier with the command we executed).

Network Proxy Settings in OS X

You can enable the Exclude simple hostnames option if you plan on doing anything regarding other machines on the local network (local to the client). This is so that if you want to access a machine by it’s DNS name, the proxy doesn’t steal that request. This is useful if you want to do work at a corporate office, for example.

时间: 2024-11-10 00:08:59

Really simple SSH proxy (SOCKS5)的相关文章

PHP通过ssh或socks5读取远程服务器的mysql数据库

https://bbs.csdn.net/wap/topics/200002080 大概描述:A:本地机器B:远程ssh或socks5机器C:mysql数据库所在服务器 要求:本地A机器使用ssh或socks5连接到远程B机器上以后,再从C机器获取数据库信息. 注:因为A不能直接访问到C机器,而B可以访问C,A只能通过ssh或socks5访问B. 请高手各个思路吧!!!我总觉得在本地使用无法代码实现,主要还是想不通,少根筋!还有,尽量不要在B上直接做端口转发,因为代码不好控制,如果一不小心掉线了

SSH proxy

# for Linux ssh [email protected] -P 22 -C -N -D 127.0.0.1:6500 # for windows(PuTTY) plink [email protected] -P 22 -C -N -D 127.0.0.1:6500 其中-P为端口,-C表示压缩,-N表示不打开远程命令窗口(Don’t start a remote command or shell at all),-D表示转发端口.这样只要在本地客户端设置代理服务器为127.0.0.1

ssh proxy配置

在.ssh目录下新建config文件,并添加以下内容: Host 10.100.101.123 ProxyCommand=nc -X 5 -x [proxyip:proxyport] %h %p

github配置SSH proxy

在windows users 用户目录下生成config文件,如在C:\Users\your_user_name\.ssh 目录下,找到config文件,如果没有新建一个,写入如下内容: Host github.com ProxyCommand connect -H 127.0.0.1:1080 %h 22 原文地址:https://www.cnblogs.com/roadwide/p/10336236.html

Turn any Linux computer into SOCKS5 proxy in one command

src: http://www.catonmat.net/blog/linux-socks5-proxy/ I thought I'd do a shorter article on catonmat this time. It goes hand in hand with my upcoming article series on "100% technical guide to anonymity" and it's much easier to write larger arti

mac下给git://协议设置代理Proxy

这几天被搞残了, 在clone项目的时候,必须要使用git://协议 , 所以设置的http https协议代理都不行, 在网上找了好多资料都没有. 功夫不负有心人,最后终于给我搞定了. 一般在中国用git协议clone项目速度都只有几kb/s, 被GFW那几个sb给kill了. 打开命令行: 1, sudo vi ~/.socks5proxyssh #!/bin/sh ssh -o ProxyCommand="/Users/tian/.socks5proxywrapper %h %p"

关于Mac下的SSH客户端iterm2等配置

linux后台开发的同学们晓得,在windows下有xshell\securecrt这样优秀的ssh客户端软件.mac下查找了下,有securecrt mac版,网上也有破解的,试用了一段时间,一个问题始终没有能解决——ssh链接偶尔会断掉.关于这个问题,先说下leby的工作环境吧:我们是不能直接ssh目标主机的,必须用ssh代理中转,于是搭建了一个HTTP的proxy,这之前在windows下xshell工作很好.在mac的scrt下,总是会随机掉线,一些超时配置当然是试过的,不能解决问题.

配置git使用socks5代理

git config --global http.proxy 'socks5://127.0.0.1:1080' git config --global https.proxy 'socks5://127.0.0.1:1080'

ssh的一些小操作

不让对方执行w的时候看到我 ssh -T [email protected] bin/sh -i 还有一个技巧:远程登录时防止被记录到knowhosts文件(默认为~/.ssh/knowhosts) ssh -o UserKnownHostsFile=/dev/null -T [email protected] /bin/bash -i 远程登录SSH后第一件事 unset HISTFILE;export HISTFILE=;export HISTFILE=/dev/null;export HI