https://avatars.githubusercontent.com/u/103393591

在Pycharm上连接远程虚拟环境进行使用

前言

相信通过前面教程,大部分问题都解决了,目前就剩一个Pycharm怎么连接远程的LXC容器运行Python项目的问题了。

(为什么不用VSCODE?因为它没有官方支持的远程开发/SSH开发的功能,只有相关的第三方插件实现了类似的功能但并不好用,所以我选择了Pycharm)

给机房的Ubuntu22.04安装LXD共享GPU资源

前言

为什么使用LXD? 因为宿主机不支持嵌套虚拟化,没有硬件加速没法搞PVE的虚拟机,开容器比较好。由于宿主机是Ubuntu22,自然选择LXD而不是INCUS了,因为后者在ubuntu24以上以及debian13以上才有官方支持包,其他低版本的系统只有第三方编译的包,有问题难处理。

给机房的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

如果还是不行,使用