Forward HTTP through an intermediary server (Local Port Forwarding)
This will tunnel HTTP requests to one given domain and port through an intermediary SSH server:
ssh -L 8080:targethost:80 tunnelhost
http://localhost:8080 will now connect you to http://targethost:80, tunnelling all data through tunnelhost
via SSH.
Note that the connection between tunnelhost and targethost will still be unencrypted in this example.
Related cards:
Run multiple local webricks at the same time using different ports
If you specify different ports, you can run multiple local webricks with rails server --port=300X
at the same time.
How to run a small web server (one-liner)
Sometimes you just want to have a small web server that serves files to test something.
Serve the current directory
On Ruby 1.9.2+ you can do the following (".
" for current directory).
ruby -run -ehttpd . -p8000
Python 2.x offers a s...
Test whether Perfect Forward Secrecy (PFS) is enabled on a server (using OpenSSL)
Use the following command to test if a server (in this example: makandra.com on port 443) uses Perfect Forward Secrecy (PFS):
openssl s_client -connect makandra.com:443 -cipher ECDHE-RSA-RC4-SHA
You should see something like the following:
...
Debug SAML in development using a local keycloak server
Developing or debugging SAML functionality can be a hassle, especially when you need to go back and forth with someone external who is managing the identity provider (IDP).
But you can setup a local keycloak server t...
Read your mail in networks that forbid e-mail traffic
If you are connected with a network that forbids e-mail traffic but allows SSH, you can tunnel your e-mail connection through a trusted, intermediary server:
sudo ssh -i /home/local-user/.ssh/local-user.key -L 143:mail-server.tld:143 remote-...
Using ngrok for exposing your development server to the internet
Sometimes you need to access a dev server running on localhost from another machine that is not part of the same network. Maybe you want to use your phone to test a web page, but are only in a guest WiFi. In the past, we often used [some port forw...
Install a local Gemfile on a remote server
Call with the server's hostname (and user if you have no SSH agent), e.g.
install-gems-remotely my.server.com
# or without agent:
install-gems-remotely me@my.server.com
When you call it from a rails directory, it uploads your `Gemfil...
How to find out what is running on a port on a remote machine
By convention, common protocols use a defined port, like 80 for HTTP or 443 for HTTPS.
You can use nmap
to find out what service is running behind a given port, and most often see some details about it. This can be helpful if servers don't offe...
Make Capistrano use SSH Key Forwarding
When deploying code with Capistrano (depending on your configuration) at some point Capistrano tries to check out code from your repository. In order to do so, Capistrano connects to your repository server from the application server you're deploy...