Yuri Slobodyanyuk Blog on Information Security 2024年09月12日
Two tips to secure SSH access from specific IPs to specific users in Checkpoint or any Linux
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

文章介绍了保障SSH访问Checkpoint防火墙/Linux服务器安全的两个技巧,强调SSH访问的重要性及需高度安全保障。

🎯更改监听端口:通过修改/etc/ssh/sshd_config文件中的端口设置,并在防火墙规则中允许该端口的传入连接,可使攻击系统变得更困难。如将端口从22改为5022。

🚫限制SSH访问的用户和IP地址:OpenSSH可限制特定用户对特定IP地址的访问。如限制所有SSH用户从特定IP(如99.19.19.0/24)访问,或限制某些用户从特定IP访问而允许其他用户从任意地址访问。

📋其他资源:文章还提到可按时间限制SSH访问、防止SSH会话超时、增加SSH日志保留等内容。

Today I'll bring you two tips to secure SSH access to the Checkpoint firewall/Linux server beyond firewall rules itself. SSH access is the most powerful way to own the firewall so it should be secured to the paranoid level and even then it is never enough.

Tip 1 Change the listening port.
You may say obscurity is not security but I will not agree - any measure that makes attacking your system harder without much burden on you is valid. After all there is no such thing total security, only endless arms race. Checkpoint just being a Linux in disguise uses OpenSSH server so changing the port is done via :
NOTE before changing listening port don't forget to allow incoming connection on this port in firewall rules.

/etc/ssh/sshd_config
#Port 22

You change the above line to (if say I want to change port to 5022):

Port 5022

Then save , then restart the SSH daemon:

[Expert@fireball]#service sshd restart

Now you connect to the firewall #ssh -p 5022 user@IP

Tip 2 Limit SSH access per user and per IP address

Openssh provides the possibility to restrict access for specific user to specific IP addresses. I will look here at few potential scenarios.

Case 1 Limit all SSH users to access from specific IP , here from network 99.19.19.0/24:

At the bottom of the same file /etc/ssh/sshd_config I add:

AllowUsers *@99.19.19.*

Save , restart SSH daemon and this will take effect - only users coming from network99.19.19.0/24 will be able to login by ssh , any other source IP will always get "Wrong username or password"

Case 2 Limit some users to access from specific IPs but allow others from Any.
Checkpoint comes with default user admin that people often do not change, and I concluded over the years that changing people's bad behavior is much harder than changing firewalls. So I do this:When both me and client are managing the firewall, I create the username for me , here yurisk and restrict the username admin to internal networks (for emergency cases) and his specific IP. Here my user is yurisk, client's user is admin, the LAN is 10.88.88.0/24 and client's WAN IP is 123.123.123.10

/etc/ssh/sshd_config:

AllowUsers  admin@123.123.123.10 admin@10.88.88.*  yurisk

Now the user admin will be able to connect from 123.123.123.123 or 10.88.88.0/24 IP addresses only, while yurisk will be able to connect from anywhere.

Resources

Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

SSH访问 安全保障 监听端口 IP限制
相关文章