remap port 80 to 22
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I would like to remap incoming requests on port 80 to port 22 and tried the following: sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 22
but still, ssh -i key user@host -p 80
would not let me connect, why not I'm wondering?
EDIT1
$ sudo iptables-save -c
sudo: unable to resolve host DevRon
# Generated by iptables-save v1.6.0 on Mon Sep 3 00:23:20 2018
*nat
:PREROUTING ACCEPT [21:1260]
:INPUT ACCEPT [21:1260]
:OUTPUT ACCEPT [254:15716]
:POSTROUTING ACCEPT [254:15716]
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 22
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 22
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
COMMIT
# Completed on Mon Sep 3 00:23:20 2018
# Generated by iptables-save v1.6.0 on Mon Sep 3 00:23:20 2018
*filter
:INPUT ACCEPT [41307:2896000]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [41123:2886089]
COMMIT
# Completed on Mon Sep 3 00:23:20 2018
ssh iptables port
 |Â
show 3 more comments
up vote
0
down vote
favorite
I would like to remap incoming requests on port 80 to port 22 and tried the following: sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 22
but still, ssh -i key user@host -p 80
would not let me connect, why not I'm wondering?
EDIT1
$ sudo iptables-save -c
sudo: unable to resolve host DevRon
# Generated by iptables-save v1.6.0 on Mon Sep 3 00:23:20 2018
*nat
:PREROUTING ACCEPT [21:1260]
:INPUT ACCEPT [21:1260]
:OUTPUT ACCEPT [254:15716]
:POSTROUTING ACCEPT [254:15716]
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 22
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 22
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
COMMIT
# Completed on Mon Sep 3 00:23:20 2018
# Generated by iptables-save v1.6.0 on Mon Sep 3 00:23:20 2018
*filter
:INPUT ACCEPT [41307:2896000]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [41123:2886089]
COMMIT
# Completed on Mon Sep 3 00:23:20 2018
ssh iptables port
1
are you doing this from remote or from host itself?
â A.B
Sep 3 at 0:07
@A.B from remote, I don't have "physical" access to this machine
â cerr
Sep 3 at 0:09
1
The wholeiptables-save -c
output would help best
â A.B
Sep 3 at 0:19
@A.B please see EDIT1 above, the8080
rule is just a remnant from testing i've done - that's also the reason why to80
-rule shows up twice....
â cerr
Sep 3 at 0:24
There's no hit on those rules, even if they (well the 1st) should be working. Are you able to see such traffic with tcpdump -n -i interface tcp port 80 (tcpdump captures before nat, so you should see something there)
â A.B
Sep 3 at 0:29
 |Â
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to remap incoming requests on port 80 to port 22 and tried the following: sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 22
but still, ssh -i key user@host -p 80
would not let me connect, why not I'm wondering?
EDIT1
$ sudo iptables-save -c
sudo: unable to resolve host DevRon
# Generated by iptables-save v1.6.0 on Mon Sep 3 00:23:20 2018
*nat
:PREROUTING ACCEPT [21:1260]
:INPUT ACCEPT [21:1260]
:OUTPUT ACCEPT [254:15716]
:POSTROUTING ACCEPT [254:15716]
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 22
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 22
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
COMMIT
# Completed on Mon Sep 3 00:23:20 2018
# Generated by iptables-save v1.6.0 on Mon Sep 3 00:23:20 2018
*filter
:INPUT ACCEPT [41307:2896000]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [41123:2886089]
COMMIT
# Completed on Mon Sep 3 00:23:20 2018
ssh iptables port
I would like to remap incoming requests on port 80 to port 22 and tried the following: sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 22
but still, ssh -i key user@host -p 80
would not let me connect, why not I'm wondering?
EDIT1
$ sudo iptables-save -c
sudo: unable to resolve host DevRon
# Generated by iptables-save v1.6.0 on Mon Sep 3 00:23:20 2018
*nat
:PREROUTING ACCEPT [21:1260]
:INPUT ACCEPT [21:1260]
:OUTPUT ACCEPT [254:15716]
:POSTROUTING ACCEPT [254:15716]
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 22
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 22
[0:0] -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
COMMIT
# Completed on Mon Sep 3 00:23:20 2018
# Generated by iptables-save v1.6.0 on Mon Sep 3 00:23:20 2018
*filter
:INPUT ACCEPT [41307:2896000]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [41123:2886089]
COMMIT
# Completed on Mon Sep 3 00:23:20 2018
ssh iptables port
ssh iptables port
edited Sep 3 at 0:24
asked Sep 3 at 0:01
cerr
64872238
64872238
1
are you doing this from remote or from host itself?
â A.B
Sep 3 at 0:07
@A.B from remote, I don't have "physical" access to this machine
â cerr
Sep 3 at 0:09
1
The wholeiptables-save -c
output would help best
â A.B
Sep 3 at 0:19
@A.B please see EDIT1 above, the8080
rule is just a remnant from testing i've done - that's also the reason why to80
-rule shows up twice....
â cerr
Sep 3 at 0:24
There's no hit on those rules, even if they (well the 1st) should be working. Are you able to see such traffic with tcpdump -n -i interface tcp port 80 (tcpdump captures before nat, so you should see something there)
â A.B
Sep 3 at 0:29
 |Â
show 3 more comments
1
are you doing this from remote or from host itself?
â A.B
Sep 3 at 0:07
@A.B from remote, I don't have "physical" access to this machine
â cerr
Sep 3 at 0:09
1
The wholeiptables-save -c
output would help best
â A.B
Sep 3 at 0:19
@A.B please see EDIT1 above, the8080
rule is just a remnant from testing i've done - that's also the reason why to80
-rule shows up twice....
â cerr
Sep 3 at 0:24
There's no hit on those rules, even if they (well the 1st) should be working. Are you able to see such traffic with tcpdump -n -i interface tcp port 80 (tcpdump captures before nat, so you should see something there)
â A.B
Sep 3 at 0:29
1
1
are you doing this from remote or from host itself?
â A.B
Sep 3 at 0:07
are you doing this from remote or from host itself?
â A.B
Sep 3 at 0:07
@A.B from remote, I don't have "physical" access to this machine
â cerr
Sep 3 at 0:09
@A.B from remote, I don't have "physical" access to this machine
â cerr
Sep 3 at 0:09
1
1
The whole
iptables-save -c
output would help bestâ A.B
Sep 3 at 0:19
The whole
iptables-save -c
output would help bestâ A.B
Sep 3 at 0:19
@A.B please see EDIT1 above, the
8080
rule is just a remnant from testing i've done - that's also the reason why to 80
-rule shows up twice....â cerr
Sep 3 at 0:24
@A.B please see EDIT1 above, the
8080
rule is just a remnant from testing i've done - that's also the reason why to 80
-rule shows up twice....â cerr
Sep 3 at 0:24
There's no hit on those rules, even if they (well the 1st) should be working. Are you able to see such traffic with tcpdump -n -i interface tcp port 80 (tcpdump captures before nat, so you should see something there)
â A.B
Sep 3 at 0:29
There's no hit on those rules, even if they (well the 1st) should be working. Are you able to see such traffic with tcpdump -n -i interface tcp port 80 (tcpdump captures before nat, so you should see something there)
â A.B
Sep 3 at 0:29
 |Â
show 3 more comments
2 Answers
2
active
oldest
votes
up vote
1
down vote
If your objective is for SSH to listen on Port 80, you can add a second port option in /etc/ssh/sshd_config like:
Port 22
Port 80
that is my objective! Thanks!
â cerr
Sep 3 at 18:28
its lots easier than network port mapping :-)
â danblack
Sep 3 at 21:19
but it looks like it doesn't let me config two ports on that line, upon restart of ssh I get an error:/etc/ssh/sshd_config line 5: Badly formatted
â cerr
Sep 4 at 0:05
appolgies - updated.
â danblack
Sep 4 at 0:16
add a comment |Â
up vote
0
down vote
accepted
I found the answer on: https://www.howtoforge.com/community/threads/change-ssh-to-listen-on-two-ports.47365/
SSH can listen on multiple ports. Just add additional ports in sshd_config like > this:
Port 22
Port 8888
1
out of curiosity: did it work for port 80 ?
â A.B
Sep 12 at 20:21
@A.B yes, i didn't actually try 80 but I'd expect it to work just fine!
â cerr
Sep 13 at 3:01
considering the discussion before (where even tcpdump couldn't detect traffic on port 80), i'd have wanted to know in the end if it would really work specifically on port 80
â A.B
Sep 13 at 5:54
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
If your objective is for SSH to listen on Port 80, you can add a second port option in /etc/ssh/sshd_config like:
Port 22
Port 80
that is my objective! Thanks!
â cerr
Sep 3 at 18:28
its lots easier than network port mapping :-)
â danblack
Sep 3 at 21:19
but it looks like it doesn't let me config two ports on that line, upon restart of ssh I get an error:/etc/ssh/sshd_config line 5: Badly formatted
â cerr
Sep 4 at 0:05
appolgies - updated.
â danblack
Sep 4 at 0:16
add a comment |Â
up vote
1
down vote
If your objective is for SSH to listen on Port 80, you can add a second port option in /etc/ssh/sshd_config like:
Port 22
Port 80
that is my objective! Thanks!
â cerr
Sep 3 at 18:28
its lots easier than network port mapping :-)
â danblack
Sep 3 at 21:19
but it looks like it doesn't let me config two ports on that line, upon restart of ssh I get an error:/etc/ssh/sshd_config line 5: Badly formatted
â cerr
Sep 4 at 0:05
appolgies - updated.
â danblack
Sep 4 at 0:16
add a comment |Â
up vote
1
down vote
up vote
1
down vote
If your objective is for SSH to listen on Port 80, you can add a second port option in /etc/ssh/sshd_config like:
Port 22
Port 80
If your objective is for SSH to listen on Port 80, you can add a second port option in /etc/ssh/sshd_config like:
Port 22
Port 80
edited Sep 4 at 0:16
answered Sep 3 at 1:31
danblack
2294
2294
that is my objective! Thanks!
â cerr
Sep 3 at 18:28
its lots easier than network port mapping :-)
â danblack
Sep 3 at 21:19
but it looks like it doesn't let me config two ports on that line, upon restart of ssh I get an error:/etc/ssh/sshd_config line 5: Badly formatted
â cerr
Sep 4 at 0:05
appolgies - updated.
â danblack
Sep 4 at 0:16
add a comment |Â
that is my objective! Thanks!
â cerr
Sep 3 at 18:28
its lots easier than network port mapping :-)
â danblack
Sep 3 at 21:19
but it looks like it doesn't let me config two ports on that line, upon restart of ssh I get an error:/etc/ssh/sshd_config line 5: Badly formatted
â cerr
Sep 4 at 0:05
appolgies - updated.
â danblack
Sep 4 at 0:16
that is my objective! Thanks!
â cerr
Sep 3 at 18:28
that is my objective! Thanks!
â cerr
Sep 3 at 18:28
its lots easier than network port mapping :-)
â danblack
Sep 3 at 21:19
its lots easier than network port mapping :-)
â danblack
Sep 3 at 21:19
but it looks like it doesn't let me config two ports on that line, upon restart of ssh I get an error:
/etc/ssh/sshd_config line 5: Badly formatted
â cerr
Sep 4 at 0:05
but it looks like it doesn't let me config two ports on that line, upon restart of ssh I get an error:
/etc/ssh/sshd_config line 5: Badly formatted
â cerr
Sep 4 at 0:05
appolgies - updated.
â danblack
Sep 4 at 0:16
appolgies - updated.
â danblack
Sep 4 at 0:16
add a comment |Â
up vote
0
down vote
accepted
I found the answer on: https://www.howtoforge.com/community/threads/change-ssh-to-listen-on-two-ports.47365/
SSH can listen on multiple ports. Just add additional ports in sshd_config like > this:
Port 22
Port 8888
1
out of curiosity: did it work for port 80 ?
â A.B
Sep 12 at 20:21
@A.B yes, i didn't actually try 80 but I'd expect it to work just fine!
â cerr
Sep 13 at 3:01
considering the discussion before (where even tcpdump couldn't detect traffic on port 80), i'd have wanted to know in the end if it would really work specifically on port 80
â A.B
Sep 13 at 5:54
add a comment |Â
up vote
0
down vote
accepted
I found the answer on: https://www.howtoforge.com/community/threads/change-ssh-to-listen-on-two-ports.47365/
SSH can listen on multiple ports. Just add additional ports in sshd_config like > this:
Port 22
Port 8888
1
out of curiosity: did it work for port 80 ?
â A.B
Sep 12 at 20:21
@A.B yes, i didn't actually try 80 but I'd expect it to work just fine!
â cerr
Sep 13 at 3:01
considering the discussion before (where even tcpdump couldn't detect traffic on port 80), i'd have wanted to know in the end if it would really work specifically on port 80
â A.B
Sep 13 at 5:54
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I found the answer on: https://www.howtoforge.com/community/threads/change-ssh-to-listen-on-two-ports.47365/
SSH can listen on multiple ports. Just add additional ports in sshd_config like > this:
Port 22
Port 8888
I found the answer on: https://www.howtoforge.com/community/threads/change-ssh-to-listen-on-two-ports.47365/
SSH can listen on multiple ports. Just add additional ports in sshd_config like > this:
Port 22
Port 8888
answered Sep 4 at 0:07
cerr
64872238
64872238
1
out of curiosity: did it work for port 80 ?
â A.B
Sep 12 at 20:21
@A.B yes, i didn't actually try 80 but I'd expect it to work just fine!
â cerr
Sep 13 at 3:01
considering the discussion before (where even tcpdump couldn't detect traffic on port 80), i'd have wanted to know in the end if it would really work specifically on port 80
â A.B
Sep 13 at 5:54
add a comment |Â
1
out of curiosity: did it work for port 80 ?
â A.B
Sep 12 at 20:21
@A.B yes, i didn't actually try 80 but I'd expect it to work just fine!
â cerr
Sep 13 at 3:01
considering the discussion before (where even tcpdump couldn't detect traffic on port 80), i'd have wanted to know in the end if it would really work specifically on port 80
â A.B
Sep 13 at 5:54
1
1
out of curiosity: did it work for port 80 ?
â A.B
Sep 12 at 20:21
out of curiosity: did it work for port 80 ?
â A.B
Sep 12 at 20:21
@A.B yes, i didn't actually try 80 but I'd expect it to work just fine!
â cerr
Sep 13 at 3:01
@A.B yes, i didn't actually try 80 but I'd expect it to work just fine!
â cerr
Sep 13 at 3:01
considering the discussion before (where even tcpdump couldn't detect traffic on port 80), i'd have wanted to know in the end if it would really work specifically on port 80
â A.B
Sep 13 at 5:54
considering the discussion before (where even tcpdump couldn't detect traffic on port 80), i'd have wanted to know in the end if it would really work specifically on port 80
â A.B
Sep 13 at 5:54
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f466471%2fremap-port-80-to-22%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
are you doing this from remote or from host itself?
â A.B
Sep 3 at 0:07
@A.B from remote, I don't have "physical" access to this machine
â cerr
Sep 3 at 0:09
1
The whole
iptables-save -c
output would help bestâ A.B
Sep 3 at 0:19
@A.B please see EDIT1 above, the
8080
rule is just a remnant from testing i've done - that's also the reason why to80
-rule shows up twice....â cerr
Sep 3 at 0:24
There's no hit on those rules, even if they (well the 1st) should be working. Are you able to see such traffic with tcpdump -n -i interface tcp port 80 (tcpdump captures before nat, so you should see something there)
â A.B
Sep 3 at 0:29