ok. I’ve fixed it. the main issue is that if you connect through a 3G USB dongle you don’t have a public IP address but a network one. so you need a reverse connection. to do that, just act that way:
suppose you are trying to connect via a windows machine with a fixed ip and with a port forwarding in the router for port 22, with user USER and password psw
on raspberry machine, execute this command after the 3G connection:
ssh -R yyyy:localhost:22 USER@xxx.xxx.xxx.xxx
where yyyy is a free port, xxx.xxx.xxx.xxx the fixed ip of the windows machine. once connected, authenticate with the windows USER psw. use sshpass -R yyyy:localhost:22 -p ‘psw’ USER@xxx.xxx.xxx.xxx
install sshpass with apt-get install sshpass
replace psw with the windows USER password
you can use a ssh server (a free one such bitvise ssh server) running on the windows machine to get the connection.
on the windows machine, using a ssh client issue the command
ssh localhost -p yyyy where yyyy is the same port of the raspberry connection. you will get reverse access to the raspberry pi machine connected to the internet through a 3G USB dongle..
that’s all. works perfectly.