Showing posts with label internet. Show all posts
Showing posts with label internet. Show all posts

Monday, March 20, 2023

Running HTTPS and SSH over the same port with SSLH

Do you need to access your network services from remote locations but are blocked by firewalls or other
access restrictions? You might want to try SSLH, a powerful open-source tool that enables you to run multiple network services over a single port. This allows you to bypass firewalls and access your network services from anywhere. Here will show you how to use SSLH to run both HTTPS and SSH on the same port, but SSLH also supports HTTP and OpenVPN. 

Installing SSLH
SSLH is available in most Linux distributions' package managers, so installation is straightforward. You can install SSLH using the following command:

$ sudo apt-get install sslh

Configuring SSLH
Once SSLH is installed, you need to configure it to run both HTTPS and SSH on the same port. The configuration file for SSLH is usually located at /etc/default/sslh. In the configuration below SSLH listens on all available network interfaces on port 443, and it proxies SSH to port 22 of localhost and HTTPS to port 2443 of localhost. 

DAEMON_OPTS="-u sslh -p 0.0.0.0:443 -s 127.0.0.1:22 -l 127.0.0.1:2443 -P /var/run/sslh.pid"
RUN=yes

Before restarting SSLH, make sure to configure your web server to listen to 2443 instead of 443. Then, restart SSLH with

$ /etc/init.d/sslh start

Testing SSLH
To test SSLH, you can try accessing both the HTTPS and SSH services through the SSLH port. For example, to access HTTPS, open a web browser and navigate to https://<your-server-address>:443. To access SSH, open a terminal and use the ssh command  ssh your-server-address -p 443



Friday, February 12, 2021

nettop: monitor the per-process bandwidth usage in OSX

This command will display the network usage of all the running processes


   nettop -P -k state,interface -d -s 3


Flags explained:

-s refreshes every 3 seconds

-P collapses the rows of each parent process

-k state,interface removes less informative columns that stand between you and the bytes in/out columns

-d activates the delta option (same as pressing the d button)

Use the h button or run man nettop for some more options.


source: https://apple.stackexchange.com/questions/16690/how-can-i-see-what-bandwidth-each-app-or-process-is-using

Saturday, February 23, 2019

Latex code and other tools for making neural networks diagrams


 PlotNeuralNet generates tikz code (for Latex) for illustrating a network architectures




NN-SVG is an online tool for illustrating simple architectures and that generates SVG code

Tensorspace.js is a web-based tool that takes keras network definitions and produces beautiful 3D representations on the browser that are also functional!

Netscope is a web-based tool for visualizing neural network architectures for the moment only supports Caffe's prototxt format




Have a look at the stackexchange thread about this topic: https://datascience.stackexchange.com/questions/12851/how-do-you-visualize-neural-network-architectures

Sources:
https://github.com/HarisIqbal88/PlotNeuralNet
http://alexlenail.me/NN-SVG/LeNet.html
https://tensorspace.org/html/docs/startHello.html
http://ethereon.github.io/netscope/quickstart.html
https://www.draw.io/ (for manual drawing from elementary shapes)

Saturday, June 15, 2013

OSX: Start SSH socks proxy and change network settings from the command line

Everybody loves to travel. I also enjoy to experience the internet from other places, but this I can do without leaving my house. All I need is a remote unix computer which I can access by SSH.

The script below sets up SSH dynamic port forwarding and changes the network proxy settings all by itself. When communication is cut, with Ctrl-D, it goes back to the usual proxy configuration (no proxy). Tested on OSX 10.6.8.


#!/bin/bash
#title           :socksProxySSH.sh
#description     :initiates SSH dynamic port forwarding and sets up 
#                 the network proxy settings for you
#author          :Gabriele Facciolo (http://linuxtoosx.blogspot.com/)
#date            :20130615
#version         :1.0
#OSX version     :Tested on OSX 10.6.8  
#usage           :socksProxySSH.sh [remoteHost [localPort (default:1080)]]

DEFAULTSSHHOST=""
DEFAULTLOCALSOCKSPORT=1080

# DEAL WITH COMMAND LINE PARAMETERS
if [ "${1}" != "" ]
then
   SSHHOST=$1
else
   SSHHOST=$DEFAULTSSHHOST
fi
if [ "${2}" != "" ]
then
   LOCALSOCKSPORT=$2
else
   LOCALSOCKSPORT=$DEFAULTLOCALSOCKSPORT
fi
# SORRY NO SSHHOST
if [ "${SSHHOST}" == "" ]
then 
   echo "${0}: initiates SSH dynamic port forwarding and "
   echo "sets up the network proxy settings for you."
   echo ""
   echo "    Usage:   ${0} [remoteHost [localPort(default:1080)]]"
   echo ""
   echo "Indicate a remoteHost, or set the DEFAULTSSHHOST variable" 
   exit 1
fi


# ENABLE SOCKS ON ACTIVE INTERFACES 
networksetup -listallnetworkservices | grep -v asterisk | while read line ; do 
t=`networksetup -getinfo "$line" | grep "IP address" | grep -v none`
if [ "$t" ]; then
   tt=`networksetup -getsocksfirewallproxy "$line" | grep -v Authenticated | grep "Enabled: No"` 
   if [ "$tt" ]; then
      echo Enabling SOCKS on $line
      networksetup -setsocksfirewallproxy "$line" localhost $LOCALSOCKSPORT
   fi
fi
done 


# OPEN CONNECTION AND INITIATE SOCKS SERVER
echo ""
echo "INITIATING SSH CONNECTION AND SOCKS SERVER..."
echo "========================================================="
echo "TO DISCONNECT FIRST HIT Ctrl-D, WAIT A SECOND THEN Ctrl-C"
echo "========================================================="
echo ""
ssh -C -D *:$LOCALSOCKSPORT $SSHHOST


# DISABLE SOCKS ON ACTIVE INTERFACES 
networksetup -listallnetworkservices | grep -v asterisk | while read line ; do 
t=`networksetup -getinfo "$line" | grep "IP address" | grep -v none`
if [ "$t" ]; then
   tt=`networksetup -getsocksfirewallproxy "$line" | grep -v Authenticated | grep "Enabled: Yes"` 
   if [ "$tt" ]; then
      echo Disabling SOCKS on $line
      networksetup -setsocksfirewallproxystate "$line" off
   fi
fi
done 



Description of the key commands:
  • networksetup -listallnetworkservices
    Displays a list of all the network services on the server's hardware ports. An asterisk (*) denotes that a network service is disabled.
    Sample output:
             USB Ethernet
             AirPort
             Bluetooth DUN
  • networksetup -getinfo "Airport"
    Displays the IP address, subnet mask, router, and hardware address for the device that you specify.
  • networksetup -getsocksfirewallproxy Airport
    Displays SOCKS proxy (server, port, enabled value) info for the device.
    Sample output:
             Enabled: No
             Server: localhost
             Port: 1080
             Authenticated Proxy Enabled: 0
  • networksetup -setsocksfirewallproxy Airport localhost 1080
    Set and enable the SOCKS proxy server  localhost:1080.
  •  ssh -C -D *:1080 your.remote.host
    Launch ssh with dynamic port forwarding
  • networksetup -setsocksfirewallproxystate Airport off
    Disables SOCKS proxy.

Sources: