Introduction

The workstation is a Dell Precision-5820 with 64 GB of RAM and 2 TB of SSD. The OS is Ubuntu Linux. The workstation is used for research and development.

To set up the SSH server

  1. Install OpenSSH Server: If not already installed, you need to install the OpenSSH Server software. You can do this by opening a terminal and running:
    sudo apt update
    sudo apt install openssh-server
    
  2. Check SSH Service Status: Ensure that the SSH service is running with the command:
    sudo systemctl status ssh
    
  3. Configure SSH (Optional): You can configure SSH settings by editing the SSH configuration file:
    sudo nano /etc/ssh/sshd_config
    

    Here, you can change settings like the port number, permit root login, and more. After editing, restart the SSH service to apply changes:

    sudo systemctl restart ssh
    
  4. Firewall Configuration: Make sure the firewall allows SSH connections. You can allow SSH through the firewall with:
    sudo ufw allow ssh
    

    and enable the firewall using:

    sudo ufw enable
    
  5. Find Your Workstation’s IP Address: You need to know your workstation’s IP address to connect from another computer. You can find it by running:
    ip a
    
  6. Connect from Campus Network: From another computer on the campus network, you can connect to your workstation using:
    ssh username@your_workstation_ip
    

    Replace username with your username on the Ubuntu workstation and your_workstation_ip with the workstation’s IP address.

  7. Additional Configurations (If Needed):
    • Static IP: Consider setting a static IP for the workstation if you don’t want its IP to change.
    • Port Forwarding: If you need to access the server from outside the campus network, you might need to set up port forwarding on your network router.
    • SSH Key Authentication: For added security, consider setting up SSH key-based authentication.

Configure the ssh client

As for editing the SSH configuration file, here are some common changes you might consider:

  1. Change the Default SSH Port (Optional for Security): By default, SSH uses port 22. Changing this to a non-standard port can add a layer of security through obscurity.
    • To change the port, find the line in /etc/ssh/sshd_config that says #Port 22 and change it to something like Port 22 (or another port of your choice).
  2. Disable Root Login (Recommended for Security): To prevent the root user from logging in via SSH, find the line that says #PermitRootLogin yes and change it to PermitRootLogin no.

  3. Allow or Deny Specific Users (Optional): You can specify which users are allowed or denied SSH access.
    • To allow specific users, add a line like AllowUsers jiahuic (replace jiahuic with the desired username).
    • To deny specific users, add a line like DenyUsers someuser.
  4. Use SSH Key Authentication (Recommended for Security): For added security, consider setting up SSH key-based authentication instead of using password authentication. This involves generating an SSH key pair and adding the public key to the ~/.ssh/authorized_keys file on your server.

After making any changes, save the file and restart the SSH service to apply them:

sudo systemctl restart ssh

With these settings, you can connect to your server from another computer on your campus network using:

ssh username@your_workstation_ip
  1. Link local ssh key to remote server: To link your local ssh key to the remote server, you can use the following command:
    ssh-copy-id -i ~/.ssh/id_rsa.pub username@your_workstation_ip
    

    This command will copy your local ssh key to the remote server. You can then use the following command to login to the remote server:

    ssh username@your_workstation_ip
    

Server Sleep and Suspend Modes

To ensure your server remains active and doesn’t enter a sleep mode (which can lead to the ‘client_loop: send disconnect: Broken pipe’ error during SSH sessions), you can configure your Ubuntu server to disable sleep and suspend modes. Here’s how to do it:

  1. Disable Sleep and Suspend Using System Settings:
    • Open the terminal.
    • Run the following command to prevent the server from sleeping:
      sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
      
    • This command stops the system from entering sleep, suspend, hibernate, or hybrid-sleep states.
  2. Edit Power Management Settings:
    • If you have a graphical interface, you can also change these settings in the power management section of your system settings. Look for options like “When the lid is closed” or “Sleep” and set them to ‘Do Nothing’ or ‘Never’.
  3. Edit/Check /etc/ssh/sshd_config:
    • Sometimes, SSH connections may drop due to server-side settings. You should ensure that ClientAliveInterval and ClientAliveCountMax are configured in your SSH configuration file (/etc/ssh/sshd_config) to keep the connection alive.
    • You can add or edit these lines:
      ClientAliveInterval 120
      ClientAliveCountMax 720
      
    • After editing, restart the SSH service:
      sudo systemctl restart ssh
      
    • These settings will send a signal every 120 seconds and keep the connection alive unless the client fails to respond 720 times.
  4. Use tmux or screen:
    • For long-running processes like Jupyter Notebooks, consider using a terminal multiplexer like tmux or screen. These tools allow you to detach from a session and leave it running in the background. You can then reattach to this session later, even after getting disconnected.
  5. Cron Job to Keep the Server Awake:
    • As a last resort, you can set up a cron job to execute a harmless command at regular intervals to keep the server awake.
    • Open the cron job file with crontab -e and add a line like: ```bash
              • /bin/true ```
    • This command does nothing but runs every minute to keep the system active.

Setup NVIDIA Driver, CUDA, and cuDNN

This part should be very careful. If you install the wrong version of NVIDIA driver or update it unproperly, you may not be able to find the driver.

  1. Disable the secure boot in the BIOS.
  2. Remove any NIVIDA driver installed by Ubuntu.
    sudo apt-get purge nvidia*
    
  3. Add the Proprietary GPU Drivers PPA.
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt-get update
    
  4. Blacklist the Nouveau driver.
    sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
    sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
    
  5. Auto-Install Recommended Drivers
    sudo ubuntu-drivers autoinstall
    

    Or, you can install the specific version of the driver.

    sudo apt-get install nvidia-driver-540
    
  6. Install CUDA Toolkit (CUDA Toolkit download page
  7. Set Environment Variables
    echo 'export PATH=/usr/local/cuda-11.2/bin${PATH:+:${PATH}}' >> ~/.bashrc
    echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
    source ~/.bashrc
    
  8. Install cuDNN (cuDNN download page)

Other Useful Tools

  • Change bash to zsh: sudo apt install zsh
  • Install nodejs:
    • Install nvm:
      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
      
    • Install nodejs:
      nvm install node