Script to create a shared Ubuntu user with sudo access, Miniconda, switch-cuda, SSH key pair, and optional data/code paths.
- Ubuntu system
- Run as root (
sudo) gitandcurlmust be installednvccalready installed on the system
sudo ./setup_user.shThe script will prompt for:
| Prompt | Required | Notes |
|---|---|---|
| Username | Yes | |
| Password | Yes | Confirmed twice |
| Sudo access | No | y/N |
| SSH key name | Yes | e.g. lab_key — generates a key pair |
| Install Miniconda | No | y/N |
| Conda envs directory | If Miniconda=y | Full path, shared across users, not chowned |
| CUDA version | No | Defaults to 11.8 |
| Extra data/code paths | No | Comma-separated full paths, created if missing |
Safe to re-run — skips steps already completed (existing user, existing key, existing Miniconda install, duplicate .bashrc entries).
At the end, the script prints a developer checklist with exact commands to connect and finish setup (create conda env, verify CUDA, etc.).
- User — created with
useradd, password set, optionally added tosudogroup - SSH key pair — ed25519 pair generated in
~/.ssh/<keyname>, public key added toauthorized_keys - Extra paths — created with
mkdir -p, owned by the new user - Miniconda — installed to
~/miniconda3,conda init bashrun,.condarcwritten to pointenvs_dirsat your shared path - switch-cuda — repo cloned to
~/switch-cuda,source ~/switch-cuda/switch-cuda.sh <version>appended to~/.bashrc
sudo pkill -u <username> # kill any running processes first
sudo userdel -r <username> # removes /home/<username> and everything in itThis removes: home dir, .ssh/ keys, ~/miniconda3, ~/switch-cuda, .bashrc, .condarc.
The conda envs directory is shared and not owned by the user, so it is not removed by userdel. Clean up manually:
sudo rm -rf /your/conda/envs/path/<env_name> # specific env
# or
sudo rm -rf /your/conda/envs/path # entire envs dirThese are also not removed by userdel. Delete manually:
sudo rm -rf /your/extra/pathRemove sudo access:
sudo deluser <username> sudoRevoke SSH access (remove key from authorized_keys):
sudo truncate -s 0 /home/<username>/.ssh/authorized_keys
# or delete specific key by editing the fileRemove Miniconda:
sudo rm -rf /home/<username>/miniconda3
sudo rm -f /home/<username>/.condarc
# also remove the conda init block from ~/.bashrc (lines between
# "# >>> conda initialize >>>" and "# <<< conda initialize <<<")Remove switch-cuda:
sudo rm -rf /home/<username>/switch-cuda
# remove the source line from ~/.bashrc:
sudo sed -i '/switch-cuda\.sh/d' /home/<username>/.bashrc