Here you will learn some handy tips on how to utilize ssh proxies efficiently in linux or bash capable terminal OSX
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 shell proxy dies and is 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 it you can use the below command to login automatically.
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
Tthe below is a working command all you need to do is update your username and hostnameIP in the command.
sshpass -f ~/sshlogin ssh -N -f -D 1081 username@hostnameorIP
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.example.com
we would add the below to your ~/.bash_aliases
alias sshvpn1=’sshpass -f ~/sshlogin ssh -N -f -D 1081 username@vpn01.example.com’
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.
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 using 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/Netflix 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 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.
We also offer custom VPN dedicated nodes for high performance and we can setup ssh proxy on those upon request.