运维小甜点之sslh使web和ssh共用一个端口

需求:

使用22端口访问web且能ssh

环境:

Centos 7 最小化安装

使用阿里云的源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

安装http ssl sslh

yum install -y httpd openssl sslh mod_ssl

开始配置:

1、https的配置

环境搭建完成后在目录/etc/httpd/conf.d下有ssl.conf文件。

https监听localhost:443端口

运维小甜点之sslh使web和ssh共用一个端口

添加https的证书

运维小甜点之sslh使web和ssh共用一个端口

2、ssh端口修改

vim /etc/ssh/sshd_config

运维小甜点之sslh使web和ssh共用一个端口

随便改个端口即可

3、修改hosts

运维小甜点之sslh使web和ssh共用一个端口

127.0.0.1 域名

4、配置sslh

vim /etc/sslh.cfg

运维小甜点之sslh使web和ssh共用一个端口

使sslh监听22端口,转发ssh包到9999端口,ssl的包转给443,host后面加域名。

5、防火墙开放443 22 9999 端口

firewall-cmd --add-port=443/tcp -permanent

firewall-cmd --reload

运维小甜点之sslh使web和ssh共用一个端口

6、启动服务。

systemctl restart ssh

systemctl restart sslh

systemctl restart httpd

运维小甜点之sslh使web和ssh共用一个端口

7、将域名映射过去

https://域名:22

https://IP:22

最后总结:

1、sslh的功能不止两个服务公用一个,比如可以加密酸(s)酸(s)乳(r)和梯子流量。

运维小甜点之sslh使web和ssh共用一个端口

2、可以在路由器上少做一个nat了。

3、注意端口冲突问题。


分享到:


相關文章: