Setting Up a Shared Python Development VM
Comprehensive Guide: Setting Up a Shared Python Development VM (VDI) on Proxmox
This guide provides detailed instructions for setting up a Debian-based Virtual Machine (VM) on Proxmox, specifically tailored for shared Python development. The VM will support multiple users, each with their own development environment, accessible via Remote Desktop Protocol (RDP).
1. Create and Configure the VM in Proxmox
- Log into your Proxmox web interface.
- Click on “Create VM” and configure as follows:
- Name: PythonDevVM (or any preferred name)
- OS: Choose Debian 11 (or the latest stable version)
- CPU: Allocate at least 4 cores for better performance
- RAM: Allocate at least 16 GB for smooth multi-user operation
- Disk: Allocate at least 100 GB to accommodate multiple users and projects
- Network: Ensure the VM is connected to your network
2. Install Debian on the VM
- Start the VM and boot from the Debian ISO.
- Follow the Debian installation process:
- Choose a minimal installation without a desktop environment
- Set up a root password and create an initial user account
3. Initial System Configuration
- After installation, start the VM and log in as root.
- Update the system:
1
apt update && apt upgrade -y
- Install essential tools:
1
apt install sudo vim wget curl git build-essential -y
- Add your initial user to the sudo group:
1
usermod -aG sudo username
4. Install and Configure SSH (Optional but Recommended)
- Install OpenSSH server:
1
apt install openssh-server -y
- Configure SSH for key-based authentication (recommended):
- Edit
/etc/ssh/sshd_config
- Set
PasswordAuthentication no
- Set
PubkeyAuthentication yes
- Edit
- Restart SSH service:
1
systemctl restart ssh
5. Create Additional User Accounts
For each developer who needs access:
- Create a new user account:
1
adduser devuser1
- Add the user to necessary groups:
1
usermod -aG sudo,ssh devuser1
Repeat this process for each developer.
6. Install Desktop Environment (XFCE)
- Install XFCE and related packages:
1
apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils -y
- Install LightDM display manager:
1
apt install lightdm -y
7. Set Up Remote Desktop Access (XRDP)
- Install XRDP:
1
apt install xrdp -y
- Configure XRDP to use XFCE:
1
echo xfce4-session > ~/.xsession
- Add all users to the ssl-cert group:
1
for user in $(getent passwd | cut -f1 -d: ); do usermod -a -G ssl-cert $user; done
- Restart XRDP service:
1
systemctl restart xrdp
8. Configure Polkit for Multi-User Sessions
- Create a Polkit configuration file:
1
nano /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla
- Add the following content:
1 2 3 4 5 6
[Allow Colord all Users] Identity=unix-user:* Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile ResultAny=yes ResultInactive=yes ResultActive=yes
9. Install Python and Development Tools
- Install Python 3 and related tools:
1
apt install python3 python3-pip python3-venv python3-dev -y
- Install additional Python tools:
1
apt install ipython3 python3-doc -y
- Verify the installation:
1 2
python3 --version pip3 --version
10. Set Up Python Virtual Environment Tools
- Install virtualenvwrapper:
1
pip3 install virtualenvwrapper
- Configure virtualenvwrapper for all users:
1 2 3
echo "export WORKON_HOME=$HOME/.virtualenvs" >> /etc/bash.bashrc echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> /etc/bash.bashrc echo "source /usr/local/bin/virtualenvwrapper.sh" >> /etc/bash.bashrc
11. Install Development Tools and IDEs
- Install Visual Studio Code:
1 2 3 4 5
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/ echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list apt update apt install code -y
- Install PyCharm Community Edition (optional):
1
snap install pycharm-community --classic
12. Install Additional Python Libraries and Tools
- Install commonly used Python libraries:
1
pip3 install numpy pandas matplotlib scikit-learn jupyter
- Install database connectors:
1
apt install python3-mysqldb python3-psycopg2 -y
13. Configure Git for Each User
For each user, set up Git configuration:
1
2
3
su - devuser1
git config --global user.name "Developer Name"
git config --global user.email "developer@email.com"
14. Set Up Shared Project Directories
- Create a shared project directory:
1 2 3
mkdir /opt/shared_projects chmod 775 /opt/shared_projects chown root:developers /opt/shared_projects
- Create a ‘developers’ group and add all dev users to it:
1 2
groupadd developers for user in devuser1 devuser2 devuser3; do usermod -aG developers $user; done
15. Configure Firewall
- Install and configure UFW:
1 2 3 4
apt install ufw -y ufw allow 22/tcp # SSH ufw allow 3389/tcp # RDP ufw enable
16. Set Up Regular System Updates
- Create a script for automatic updates:
1
nano /usr/local/bin/update-system.sh
- Add the following content:
1 2 3 4
#!/bin/bash apt update apt upgrade -y apt autoremove -y
- Make the script executable:
1
chmod +x /usr/local/bin/update-system.sh
- Set up a weekly cron job:
1
echo "0 2 * * 0 root /usr/local/bin/update-system.sh" > /etc/cron.d/update-system
17. Final Steps and Testing
- Reboot the VM:
1
reboot
- Test RDP access for each user from a client machine.
- Verify that each user can:
- Log in via RDP
- Access Visual Studio Code or PyCharm
- Create and activate Python virtual environments
- Install Python packages
- Access shared project directories
Conclusion
This guide provides a comprehensive setup for a shared Python development VM (VDI) environment on Proxmox. It allows multiple developers to work in isolated environments while sharing resources and project directories. Regular maintenance, security updates, and backups are crucial for keeping this development environment robust and secure.
Remember to customize this setup based on your specific needs, such as adding version control systems, continuous integration tools, or specific Python frameworks relevant to your projects.
Comments powered by Disqus.