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
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.
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 /or shell proxy dies and leaving it open gets in your way.
So for doing this my way advise the below base command.
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 ityou can use the below command to login automatically. If your a current vpn client your vpn password would be your ssh password.
sshpass -f ~/sshlogin ssh -N -f -D 1080 username@yourdomain
you can use below command to create the file
nano ~/sshlogin
or
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.
sshpass -f ~/sshlogin ssh -N -f -D 1081 username@vpn01.whattheserver.me
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
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.
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
nano ~/.bash_aliases
or
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
sshpass -f ~/sshlogin ssh -N -f -D 1081 username@vpn01.whattheserver.me
we would add the below to your ~/.bash_aliases
alias sshvpn1='sshpass -f ~/sshlogin ssh -N -f -D 1081 username@vpn01.whattheserver.me'
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 usernameto your vpn username.
alias sshvpn1='sshpass -f ~/sshlogin ssh -N -f -D 1081 username@vpn01.whattheserver.me'
alias sshvpn2='sshpass -f ~/sshlogin ssh -N -f -D 1082 username@vpn02.whattheserver.me'
alias sshvpn3='sshpass -f ~/sshlogin ssh -N -f -D 1083 username@vpn03.whattheserver.me'
alias sshvpn4='sshpass -f ~/sshlogin ssh -N -f -D 1084 username@vpn04.whattheserver.me'
alias sshvpn5='sshpass -f ~/sshlogin ssh -N -f -D 1085 username@vpn05.whattheserver.me'
alias sshvpn6='sshpass -f ~/sshlogin ssh -N -f -D 1086 username@vpn06.whattheserver.me'
alias sshvpn7='sshpass -f ~/sshlogin ssh -N -f -D 1087 username@vpn07.whattheserver.me'
alias sshvpn8='sshpass -f ~/sshlogin ssh -N -f -D 1088 username@vpn08.whattheserver.me'
alias sshvpn9='sshpass -f ~/sshlogin ssh -N -f -D 1089 username@vpn09.whattheserver.me'
Once the username is changed to yours you can add them to your ~/.bash_aliases
nano ~/.bash_aliases
Then relogin and you will be able to 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 Englishso many cool applications for foxy proxy and socks proxy with vpn's etc.
Also our vpn/ssh proxy nodes are 100% logless.
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.