remap port 80 to 22

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this question



















  • 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 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















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









share|improve this question



















  • 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 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













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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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











  • 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




    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 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








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











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





share|improve this answer






















  • 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

















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







share|improve this answer
















  • 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










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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





share|improve this answer






















  • 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














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





share|improve this answer






















  • 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












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





share|improve this answer














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






share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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












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







share|improve this answer
















  • 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














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







share|improve this answer
















  • 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












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







share|improve this answer












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








share|improve this answer












share|improve this answer



share|improve this answer










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












  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay