二叉树的博客

给机房的Ubuntu22.04的Linux进行内穿映射端口

前言

因为机房的机器没有公网IP,所以需要跳板机进行IP映射内穿,所以需要2样东西:

1
服务器A - 服务端 - 一个有公网IPV4地址的云服务器,IPV4地址本教程假设为 x.x.x.x
1
服务器B - 客户端 - 机房内的Ubuntu22.04系统的机器

这里选用goproxy进行IP内穿

给机房的Ubuntu22.04的Linux安装SSH的server

废话少说

1
sed -i 's/.*precedence ::ffff:0:0\/96.*/precedence ::ffff:0:0\/96  100/g' /etc/gai.conf
1
2
3
4
apt update
apt install openssh-server -y
systemctl enable --now ssh
systemctl status ssh
1
2
3
4
5
6
7
8
9
    sed -i 's/^#\?Port.*/Port 22/g' /etc/ssh/sshd_config
    sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
    sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
    sed -i 's/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/' /etc/ssh/sshd_config
    sed -i 's/#ListenAddress ::/ListenAddress ::/' /etc/ssh/sshd_config
    sed -i 's/#AddressFamily any/AddressFamily any/' /etc/ssh/sshd_config
    sed -i '/^#UsePAM\|UsePAM/c #UsePAM no' /etc/ssh/sshd_config
    sed -i 's/^#\?PubkeyAuthentication.*/PubkeyAuthentication no/g' /etc/ssh/sshd_config
    sed -i '/^AuthorizedKeysFile/s/^/#/' /etc/ssh/sshd_config
1
2
systemctl restart sshd
systemctl restart ssh

如果还是不行,使用