SSH Proxy How to Linux

Status
Not open for further replies.

Onessa

Active Member
99
2011
15
0
Here you will learn some handy tips on how to utilize ssh proxies efficiently in linux or bash capable terminal OSX

If you do not already have a vps or ssh shell you can use for this tutorial you can check out our very cheap vpn plans that come with ssh proxy.

First off you will want to have this package installed for linux. This will allow you to pass a password or password file to automate login
sshpass

you can use below to install this
Code:
  sudo apt-get install sshpass

Normally you see this below command used for doing dynamic socks proxy. Where “username” you would replace with your username and “yourdomain” you would replace with your ssh server ip or fully qualified hostname.

Code:
  ssh -N -D 1080 username@yourdomain
What this does is open a dynamic socks proxy on local port 1080. This will allow you to use localhost:1080 for socks 5 proxy in any socks5 capable application for network proxy.

My beef with the above command is unless you start it in screen or tmux it just hangs and and if you close it shell proxy dies and is in your way.

So for doing this my way advise the below base command.

Code:
  ssh -N -f -D 1080 username@yourdomain

the -f flag ensure its sends the process to background so you do not have to leave terminal open for the proxy to work.

So first off you want to automate your login so if you installed sshpass as advised above and make the file ~/sshlogin with your password inside it you can use the below command to login automatically. If your a current vpn client your vpn password would be your ssh password.

Code:
  sshpass -f ~/sshlogin ssh -N -f -D 1080 username@yourdomain

you can use below command to create the file

Code:
nano ~/sshlogin

or

Code:
vi ~/sshlogin

Once you have your file created and password inside it try the command from above with your username and yourdomain

If your following this guide and are a current vpn client the below is a working command all you need to do is update your username in the command.
Code:
  sshpass -f ~/sshlogin ssh -N -f -D 1081 [EMAIL="username@vpn01.whattheserver.me"]username@vpn01.whattheserver.me[/EMAIL]

If it works it will just complete without any error and you will be able to try it by pointing an application’s socks5 proxy to localhost:1081

If that works then you got password set and your ready to make this super easy to do in future without having to remember or copy and paste that command again.

What were going to do is an alias/s in your ~/.bash_aliases file.

First, edit your ~/.bashrc file and add or uncomment the following lines, if it is not already
Code:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Save it and close the file. After that, all you have to do is create a ~/.bash_aliases file and add your aliases there.

First off check if you have this file.
Code:
  cat ~/.bash_aliases

If you get an error then that means you will need to create the file

You can create it by using one of the below commands

Code:
nano ~/.bash_aliases

or

Code:
vi ~/.bash_aliases

Once created we can add our alias for proxy in there so we can have a short name that will execute the command to open proxy.
for example if we wanted to alias the below command to sshvpn1
Code:
  sshpass -f ~/sshlogin ssh -N -f -D 1081 [EMAIL="username@vpn01.whattheserver.me"]username@vpn01.whattheserver.me[/EMAIL]

we would add the below to your ~/.bash_aliases
Code:
  alias sshvpn1=’sshpass -f ~/sshlogin ssh -N -f -D 1081 [EMAIL="username@vpn01.whattheserver.me"]username@vpn01.whattheserver.me[/EMAIL]’

This will allow you to type in “sshvpn1” minus quotes in terminal and it will open the proxy for you so you do not have to remember the full command each time.
Very cool and efficient way to utilize ssh proxy from command line and it not be in your way. This should work for any ssh server if you replace the username and hostname/ip to yours.

If your a current client and you want to easily create all the aliases for our nodes for your use you can copy the below text into gedit or something first and then find and replace username to your vpn username.

Code:
alias sshvpn1=’sshpass -f ~/sshlogin ssh -N -f -D 1081 [EMAIL="username@vpn01.whattheserver.me"]username@vpn01.whattheserver.me[/EMAIL]’
alias sshvpn2=’sshpass -f ~/sshlogin ssh -N -f -D 1082 [EMAIL="username@vpn02.whattheserver.me"]username@vpn02.whattheserver.me[/EMAIL]’
alias sshvpn3=’sshpass -f ~/sshlogin ssh -N -f -D 1083 [EMAIL="username@vpn03.whattheserver.me"]username@vpn03.whattheserver.me[/EMAIL]’
alias sshvpn4=’sshpass -f ~/sshlogin ssh -N -f -D 1084 [EMAIL="username@vpn04.whattheserver.me"]username@vpn04.whattheserver.me[/EMAIL]’
alias sshvpn5=’sshpass -f ~/sshlogin ssh -N -f -D 1085 [EMAIL="username@vpn05.whattheserver.me"]username@vpn05.whattheserver.me[/EMAIL]’
alias sshvpn6=’sshpass -f ~/sshlogin ssh -N -f -D 1086 [EMAIL="username@vpn06.whattheserver.me"]username@vpn06.whattheserver.me[/EMAIL]’
alias sshvpn7=’sshpass -f ~/sshlogin ssh -N -f -D 1087 [EMAIL="username@vpn07.whattheserver.me"]username@vpn07.whattheserver.me[/EMAIL]’
alias sshvpn8=’sshpass -f ~/sshlogin ssh -N -f -D 1088 [EMAIL="username@vpn08.whattheserver.me"]username@vpn08.whattheserver.me[/EMAIL]’
alias sshvpn9=’sshpass -f ~/sshlogin ssh -N -f -D 1089 [EMAIL="username@vpn09.whattheserver.me"]username@vpn09.whattheserver.me[/EMAIL]’

Once the username is changed to yours you can add them to your ~/.bash_aliases
Code:
  nano ~/.bash_aliases

Then logout and relogin and you will be able to use all those alias's you set open an ssh proxy using sshvpn1 etc in terminal super easy.

If you want to have a specific proxy executed on login you can use the startup applications in preferences in linux to specify the command or alias to execute along with delay before it executes on login. This allows you to have the proxy automated on login going forward for maximum efficiency and easy of use. :)


You can also setup custom foxy proxy for each sshvpn in firefox and then redirect matching patterns of sites to specific proxies so you can have specific sites using a specific proxy. This is one of the best things about our vpn/ssh proxy service you can be using a Netherlands vpn node, but proxy specific sites you need in browser to usa ip so your not geoblocked etc for pandora etc if necessary
or for google search via usa ip, but all traffic by default is over NL vpn IP address so your Google searches stay in English so many cool applications for foxy proxy and socks proxy with vpn’s etc.

Also our vpn/ssh proxy nodes are 100% logless.
All OpenBSD OpenVPN on LibreSSL server.conf “verb 0” AES-256-CBC SHA512 OpenSSH Proxy

If your a current client(VPS/VPN) and need some help send in a support ticket to us under vpn support department and we would be happy to assist you.
 
Status
Not open for further replies.
Back
Top