gcloud command for free port forwarding from Google Cloud account, using reverse SSH, along with Windows batch scripts to automatically restart the SSH tunnel
0
0

gcloud compute ssh tunnel --ssh-flag "-R 43022:localhost:22" --command "sudo sshpass -p WindowsPassword ssh localhost -N -p43022 -l WindowsUsername -L:80:localhost:80 -L:443:localhost:443 -L:8333:localhost:8333 -L:8334:localhost:8334 -L:8335:localhost:8335 -L:50001:localhost:50001 -L:50002:localhost:50002 -L:50003:localhost:50003 -L:50004:localhost:50004"
Port forwarding is necessary for Bitcoin nodes to accept inbound connections, Fulcrum (Electron-Cash) servers, serving web-sites from PC & setting up a Tor relay. Unfortunately many of us like myself can't forward ports properly from fiber modem. Unlike VPN port forwarding, Google Cloud is free to try! PureVPN otoh may involve a 24 month contract. Every Google account with a proper debit card # gets 3 months free with $300 credit. I've only used $22 in 9 days, including VM setup.
Ports 80 & 443 are for HTTP & HTTPS. Ports 8333→8335 are for BCHD (full node). Ports 50001→50004 are for Fulcrum, an EC server. Port 22 is for Windows OpenSSH Server. Seeding torrents may require yet another port.
The problem is that it's quite difficult for ppl to figure out how to forward ports reliably using ssh, even if it is free. The above command requires a few things:
- "tunnel" refers to a working VM inside the cloud.
gcloud compute instances createcan be used from PowerShell, since the gcloud website is too confusing imo. There might be a firewall rule needed at gcloud's website, though. sudo apt-get install sshpassis necessary, aftergcloud compute ssh tunnelfrom PowerShell. sshpass allows combining everything into a single cmd command.- In Win10 go to Manage Optional Features & install OpenSSH Server. Optionally if you go to the Windows Services app you can check that OpenSSH Server is running properly.
- Replace WindowsPassword & WindowsUsername with your Win10 login credentials. A more secure, more complicated, option is to create a secondary non-admin account for port forwarding (
always logged in). Same sort of thing should also work for local Linux or macOS.
I recently posted a batch script to auto reset failing Wi-Fi adapters. This can be combined a new batch script which reboots the gcloud tunnel & then resets the ssh port forwarding. Copy the following into notepad & save as MaintainSSHConnection.bat
:GoTo call gcloud compute ssh tunnel --ssh-flag "-R 43022:localhost:22" --command "sudo sshpass -p WindowsPassword ssh localhost -N -p43022 -l WindowsUsername -L:80:localhost:80 -L:443:localhost:443 -L:8333:localhost:8333 -L:8334:localhost:8334 -L:8335:localhost:8335 -L:50001:localhost:50001 -L:50002:localhost:50002 -L:50003:localhost:50003 -L:50004:localhost:50004" call gcloud compute ssh tunnel --command "sudo reboot" TimeOut 15 GoTo GoTo replacing the password & username with your own, & double-click to run. It takes btwn 10 & 15 secs to reboot the Linux VM (maybe 20 is safer). I'm not sure why call is necessary.
Edit: I originally had 2 scripts here which worked together, but now I've successfully tested MaintainSSHConnection.bat on its own, without Admin privileges nor MaintainInternetConnection.bat. Also I've re-ordered the commands because it's more efficient to not always reboot first. If the SSH connection breaks, the script waits until it can reboot the gcloud VM, & then restarts after delay. It's easy to set up a secondary user account in Windows with strong password, & it'll work straight away without logging in, etc.
I'm running a Fulcrum server at bchd.tk, as well as a BCHD SLP-GraphSearch server. There's a timeout problem with the bchd-mainnet.electroncash.de server, so EC-SLP users might need an alternative! Using free gcloud port forwarding anyone can run their own graphsearch server, etc. gcloud could be like gmail for VPN! A Tor relay could also be run on the VM, possibly helping to improve the Tor network.
[link] [comments]
0
0
開始に使用しているポートフォリオを安全に接続します。







