From Scratch to Dev Ready: Setting up a New Ubuntu Server with VSCode

My trusty Ubuntu server has been running for a few years now, and it was a guinea pig for all my crazy ideas and lack of experience, so naturally it filled up with junk. I wanted to get a new one up and running, with the following essentials: Portainer, Docker, and Tailscale. In order to make working with the server easier, I wanted to get VSCode on there. Here are the steps I needed to take to get VSCode to talk to the server.

Step 1: Installing OpenSSH Server on Ubuntu

Before we can connect to our server with VSCode, we need to make sure that OpenSSH server is installed and running. By default, Ubuntu Server comes with OpenSSH server installed, but if it’s not installed on your system, you can install it by running:

bashCopyInsertsudo apt update
sudo apt install openssh-server

Step 2: Starting and Enabling OpenSSH Server

Once OpenSSH server is installed, we need to start it and enable it to start automatically on boot. Run the following commands:

bashCopyInsertsudo systemctl start ssh
sudo systemctl enable ssh

Step 3: Configuring SSH Server

Next, we need to configure the SSH server to allow password authentication (optional) and set the port number (default is 22). Edit the SSH server configuration file using:

bashCopyInsert in Terminalsudo nano /etc/ssh/sshd_config

Uncomment or add the following lines:

bashCopyInsertPasswordAuthentication yes
Port 22

Restart the SSH server to apply the changes:

bashCopyInsert in Terminalsudo systemctl restart ssh

Step 4: Creating a User and Setting Up SSH Keys (optional)

Create a new user and set up SSH keys for secure authentication. This step is optional but recommended.

Create a new user:

bashCopyInsert in Terminalsudo adduser <username>

Generate SSH keys on your local machine (if you haven’t already):

bashCopyInsert in Terminalssh-keygen -t rsa -b 4096

Copy the public key to the Ubuntu server:

bashCopyInsert in Terminalssh-copy-id <username>@<ubuntu-server-ip>

Step 5: Connecting to Ubuntu Server from VSCode

In VSCode, open the Command Palette by pressing Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (Mac). Type “Remote-SSH: Add New SSH Host” and select the command.

Enter the following details:

  • Host: <ubuntu-server-ip>
  • Username: <username>
  • Port: 22 (default)
  • Private Key: ~/.ssh/id_rsa (or the path to your private key file)

Save the configuration. You should now be able to connect to your Ubuntu server from VSCode using SSH.

That’s it! With these steps, you should be able to get VSCode connected to your new Ubuntu server. From here, you can install Portainer, Docker, and Tailscale to get your server up and running with the tools you need.

Next Steps

  • Install Portainer for easy Docker management
  • Install Docker for containerization


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *