Skip to content

Instantly share code, notes, and snippets.

@xros
Forked from lynus/wan_ssh
Created November 7, 2023 04:17
Show Gist options
  • Save xros/f432c14967efaceff9bb23383e5d779b to your computer and use it in GitHub Desktop.
Save xros/f432c14967efaceff9bb23383e5d779b to your computer and use it in GitHub Desktop.
openwrt:allow wan ssh into your wrt
by default,openwrt do not allow ssh access from wan, here are two method to change that:
1.login into your wrt from a lan host.issue the following command:
iptables -F
the command "flush away" all the firewall rules,including the one that rejects ssh request from wan.
now you can try ssh from anywhere.
aware that the firewall deactivation leads to highly security risk.and after the wrt restarts ,all default firewall configuration comes back.you hava to "flush" the rules once again.
2.add the following lines in /etc/config/firewall :
config rule
option src wan
option dest_port 22
option target ACCEPT
option proto tcp
after restart ('reboot' commmand),wrt accept port 22 request (in this case ,ssh request)from wan.
@xros
Copy link
Author

xros commented Nov 7, 2023

It works. For recent OpenWRT destros, you would need to add ' mark

config rule
        option src              'wan'
        option dest_port        '22'
        option target           'ACCEPT'
        option proto            'tcp' 

@xros
Copy link
Author

xros commented Nov 7, 2023

To start sftp on openwrt

opkg install vsftd openssh-sftp-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment