This has been a common question, which I know because I myself have searched for a solution without much luck. It's known that Proxmox Cluster requires SSH to be on port 22 to work & it doesn't support changing it as far as I'm aware. Certain circumstances dictate this might be an issue for a variety of reasons.
I think I've found a workaround: Don't change it, just restrict it with iptables, & add another port. OpenSSH can listen on however many ports you want, so you can leave the default 22 enabled, but also add another non-standard port to the config file & it will listen on both:
This assumes you're starting with an empty ruleset
Read & understand the entire thing before changing anything!
Edit /etc/ssh/sshd_config & add the additional Port line under Port 22. Save & close the file (Note: this is just a snippet of the top of the file, not the entire file):
From there, restart ssh & verify you can get in over port 2222 before continuing:
For administrative use, you could use the non-standard port 2222, which could stay open to the world. For Proxmox's cluster purposes, we can restrict port 22 with iptables.
When creating firewall rules, I always use these as a standard baseline (allow all to/from loopback & allow all established connections):
Assume 10.0.1.10 is the other Proxmox cluster node. If you have multiple nodes, add one rule per node:
Then drop the rest of the connections to port 22:
Note that I'm using "iptables -I INPUT 2". I'm specifying the rule number so it will go where I want in the INPUT chain, in that case 2. iptables processes rules from top down. If your chain is empty, you can copy & paste. If not, you'll need to adjust accordingly.
These are meant to be done on a running system, hence the use of the -I flag with the rule number after INPUT. If the system is rebooted, the rules will be lost. It is up to you to determine how to make them permanent. I haven't gotten that far myself, but there's plenty of howto's out there for doing that on debian. If you're using a script to load the rules, you'll want to change the -I flag to -A.
It's also possible you could use the new PVE Firewall in 3.3 for this, but I haven't given it a look yet.
If anyone can see a reason why this is a bad idea, please let me know. Thanks!
I think I've found a workaround: Don't change it, just restrict it with iptables, & add another port. OpenSSH can listen on however many ports you want, so you can leave the default 22 enabled, but also add another non-standard port to the config file & it will listen on both:
This assumes you're starting with an empty ruleset
Read & understand the entire thing before changing anything!
Edit /etc/ssh/sshd_config & add the additional Port line under Port 22. Save & close the file (Note: this is just a snippet of the top of the file, not the entire file):
Code:
# Package generated configuration file # See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
Port 2222
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
From there, restart ssh & verify you can get in over port 2222 before continuing:
Code:
service ssh restart
For administrative use, you could use the non-standard port 2222, which could stay open to the world. For Proxmox's cluster purposes, we can restrict port 22 with iptables.
When creating firewall rules, I always use these as a standard baseline (allow all to/from loopback & allow all established connections):
Code:
iptables -I INPUT 1 -i lo -j ACCEPT
iptables -I INPUT 2 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
Assume 10.0.1.10 is the other Proxmox cluster node. If you have multiple nodes, add one rule per node:
Code:
iptables -I INPUT 3 -m conntrack --ctstate NEW -m tcp -p tcp --source 10.0.1.10 --dport 22 -j ACCEPT
Then drop the rest of the connections to port 22:
Code:
iptables -I INPUT 4 -m tcp -p tcp --dport 22 -j DROP
Note that I'm using "iptables -I INPUT 2". I'm specifying the rule number so it will go where I want in the INPUT chain, in that case 2. iptables processes rules from top down. If your chain is empty, you can copy & paste. If not, you'll need to adjust accordingly.
These are meant to be done on a running system, hence the use of the -I flag with the rule number after INPUT. If the system is rebooted, the rules will be lost. It is up to you to determine how to make them permanent. I haven't gotten that far myself, but there's plenty of howto's out there for doing that on debian. If you're using a script to load the rules, you'll want to change the -I flag to -A.
It's also possible you could use the new PVE Firewall in 3.3 for this, but I haven't given it a look yet.
If anyone can see a reason why this is a bad idea, please let me know. Thanks!
Last edited: