Skip to main content

[OpenWRT] Port Forwarding dengan Reverse SSH (Dropbear)

Curhatan ini mengenai cara reverse ssh sehingga router kita dapat diakses melalui virtual private server. Hal ini sebagai alternatif IP publik, jika anda sudah mempunyai IP publik ya mungkin bisa menjadi sedikit informasi saja :) WhiteBox saya kebetulan menggunakan cara ini.

Sebagai mahasiswa yang tidak punya uang, maka saya mencari layanan vps gratisan karena hanya untuk belajar saja. VPS.me jawabanya, saya menemukan vps yang benar - benar gratis namun pasti ada tapinya :)

VPS.me hanya membuka 1 port untuk IPv4 yaitu untuk koneksi SSH, sedangkan anda dapat membuka port kesukaan anda tapi di IPv6. Kebetulan beberapa provider di Indonesia ini belum banyak yang menggunakan IPv6. Ya, karena kita hanya akan melakukan reverse ssh, tidak menjadi masalah. 

INGAT! ketika anda menggunakan vps yang sama seperti yang saya gunakan, bahwa port SSH tidak berada pada port 22 ! Port SSH dapat dilihat pada menu SSH di control panel akun vps anda. 

Maka dari itu, untuk beberapa perintah dibawah, harus ditambahi parameter -p <nomor port> (perintah SSH) atau -P <nomor port> (perintah scp). Tutorial dibawah ini saya ambil dari grup OpenWRT Indonesia yang bisa anda kunjungi di [ link ]. 

Ketika anda sudah selesai konfigurasi, untuk mengetesnya apakah sudah terkoneksi router <-> vps, buka vps anda dan ketikkan perintah 
ssh root@localhost -p <nomor port yg dibuka>
TUTORIAL KONFIGURASI
Saya mau share cara untuk Reverse Tunel Menggunakan Dropbear, kenapa saya menggunakan dropbear? ya karena irit memory :D cuman 4-5% ane coba menggunakan openssh sampe 10% wew.. nah untuk port forwading... bagi yang sudah punya vps ane mau share sedikit.. supaya operator local yang gak punya ip public bisa memanfaatkan ip public vps :D

saya menggunakan centOS 6 - 64bit :
Aktifkan dahulu "GatewayPorts yes" pada /etc/ssh/sshd_config di vps 

openwrt:~# dropbearkey -t rsa -f rsa_secret.txt
openwrt:~# dropbearkey  -y -f rsa_secret.txt | grep ssh > ssh_pub.txt
openwrt:~# ssh root@ip-vps

vpsmu:~# ssh-keygen -t rsa
vpsmu:~# logout

openwrt:~# scp ssh_pub.txt root@ip-vps:~/.ssh/.
openwrt:~# ssh root@ip-vps

vpsmu:~# cd ~/.ssh
vpsmu:~# cat ssh_pub.txt >> authorized_keys
vpsmu:~# chmod 600 authorized_keys
vpsmu:~# rm ssh_pub.txt
vpsmu:~# logout

openwrt:~# ssh -f -NT -R 81:192.168.1.1:80 root@ip-vps -i /root/rsa_secret.txt

Untuk lebih dari 2 port bisa menggunakan script ini, contoh untuk membuka luci, transmission dan ssh :
openwrt:~# ssh -f -NT -R 81:192.168.1.1:80 -f -NT -R 9091:192.168.1.1:9091 -f -NT -R 222:192.168.1.1:22 root@ip-vps -i /root/rsa_secret.tx
====================================================
Buat yang masih bingung untuk otomatis running ssh nya :D
ini langkahnya :
openwrt:~# vi /bin/forward.sh

isinya :
#!/bin/sh
R="ssh -f -NT -R 81:192.168.1.1:80 root@ipvps -i /root/rsa_secret.txt"
pgrep -f "$R" > /dev/null 2>&1 || $Rlalu save..openwrt:~# chmod 755 /bin/forward.sh
openwrt:~# /etc/init.d/cron stop
openwrt:~# echo "*/5 * * * * /bin/forward.sh" >> /etc/crontabs/root
openwrt:~# /etc/init.d/cron restart

Supaya saat inet down dan auto connect ane modif script anti-idle bisa dicari di doc.. :D menjadi,

#!/bin/sh
if ! ping -q -c 1 -W 3 -s 1 8.8.8.8 > /dev/null; then
 (killall ssh; ifdown wan2; sleep 3; ifup wan2) &
fi
---------------------------------------------------------------------------------------------------------------------

langkah diatas saya saring darieko.one.pl 
Thx yang udah share :D

Comments

Popular posts from this blog

HackRF Mayhem Failed to Update - M0 Guru Meditation Hard

I was on Mayhem Portapack v2.0.1 and want to upgrade to the latest stable release v2.1.0. The update went okay using the web upgrade https://hackrf.app/. But then I saw the latest nightly update and want to try it, since it has many new tools that are not yet included in the stable release. But then the update failed :( Disclaimer: I didn't take any photos of the errors, since I was focused on googling the solution. So the error was " Bad Firmware or Failed W/R error" during the upgrade process, and it was stuck. So I had to restart the device, and it was booting to the Mayhem menu, but on the bottom left, which should show the current firmware version, it was showing a  "FLASH ERR"  message. I think I should go back to the stable release, but I can't. Every time I want to flash the stable release version, the portapack will shows an error M0 Guru Meditation - Hard Fault.  There's an issue that was closed on the Mayhem GIT repo that has the same issue a...

Macintosh Classic II Brightness Issue

The Problem My Macintosh Classic II suffers from an issue where the display CRT goes dim after a few minutes on a cold boot. Every time it happens, I need to crank up the cut-off and brightness  pot behind the machine to show the image. The Analyze At first, I thought it must be the brightness issue, so I searched for the Macintosh Classic analog board schematic to check the brightness line. I found the schematic from Bomarc, and the schematic is suitable with my board, since there are two analog board versions.  I started to suspect the resistors and potentiometer on the brightness line. This Macintosh version has software-controlled brightness, so the analog board will get a 22.25 kHz square wave PBM signal from the logic board to control the brightness. I checked and replaced some resistors and cleaned the potentiometer, but nothing seems to work. The signal is there, and no sign of degradation that makes the screen dim after a few minutes.  Brightness Line So I suspec...

Fiberhome HG6145D2 Superadmin Login

Maybe some of you are using In**ehome ISP as your home internet and found out that using the provided login has minimal options to configure the router: user  user1234 I know it’s not the admin login, and that must be a full-control user account that can be used to control this router fully. So I searched and found some posts on the net and most of them are telling me to use: admin %0|F?H@f!berhO3e I tested it and it doesn’t work! But there’s more to it, you need to reset the router first by pressing the reset button on the side of the router. Then after resetting, you can log in using the admin superaccount! But keep in mind, never use the user log in again, because it will lock the super admin login until you reset the router again. Cheers 🍺