Hello Amin I will try to help you achieve what you want:
I understand you got 2 interfaces 1.1.1.1 and 2.2.2.2 and you need 1.1.1.1 to be public and 2.2.2.2 to be private with a Whitelist of IP's.
Follow this steps and I think you will be able to do it:
- Open you sshd_config file (use nano if you're a vi noob)
sudo vi /etc/ssh/sshd_config
- Add the following lines to the config file
ListenAddress 1.1.1.1
ListenAddress 2.2.2.2
Save and close the file
Restart the sshd daemon
sudo /etc/init.d/sshd restart OR sudo service sshd restart
- Check that SSH is listening to the ports you just defined
netstat -tulpn | grep :22
- Use Ubuntu's default Uncomplicated firewall to deny all traffic to your 2.2.2.2 interface
sudo ufw deny from any to 2.2.2.2 port 22
- Whitelist your IP and the ones you want to be able to access 2.2.2.2
sudo ufw allow in from 123.123.221.1 to 2.2.2.2 port 22
-
I think this is what you wanted, have a nice day!