# Setting up student development environment ###### tags: `ccss-summer-dev-projects` ## 1. Install VS Code Remote Development *Do this step from inside VS Code* Install this extension in VS Code `ms-vscode-remote.vscode-remote-extensionpack` ## 2. Set up a local SSH and connect it to Github *Do this step from the terminal on your local computer, and on Github's website* If you already have an SSH key set up with Github, you can can skip this step. Set up a new SSH key in your terminal, and add it to Github. You can use this guide: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent The basic steps for this are: First, generate the ssh key `ssh-keygen -t ed25519` Second, print out the public key. Your exact command might be a bit different. `cat ~/.ssh/id_ed25519.pub` Third, add this key to Github: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account ## 3. Set up the dev host in your SSH config *Do this step from inside VS Code* Now that you have you the Remote Extensionpack in VS Code, you should see this icon in the bottom left. You'll be able to access remote machines and dev containers through here. ![](https://i.imgur.com/ZOw9rYF.png) Click it, and it will bring up this menu: ![](https://i.imgur.com/AWnHRtK.png) From here, press "Open SSH Configuration File". There might be a few options, but you can probably just choose the first. Inside this file, you'll add this segment to the end of the file: ``` Host ccss-summer-dev-projects HostName 134.117.134.79 User angelonfira ProxyCommand ssh forestanderson@access.scs.carleton.ca -W %h:%p ``` You'll need to make two changes to this config. First, your user will be the lowercase form of your Github username, without anything else changed. Second, your proxy command will use your cmail username. For example, mine is `forestanderson`, so I use `forestanderson@access.scs.carleton.ca`. ## 4. Add your key to the SCS bastion *Do this step from the terminal on your local computer* Next, we'll add the SSH key we generated to the SCS bastion, which is the intermediate server to get access to our dev server. We're going to run this command from our local computer in the terminal, similar to step 2. Again, make sure you're using your email account name here, like `forestanderson`. For this, use the command: `ssh-copy-id forestanderson@access.scs.carleton.ca` Remember to use `@access.scs.carleton.ca` instead of `@cmail.carleton.ca`! You'll be prompted for a password once you get in to that server. It should be the same as anything else on the SCS network, such as your OpenStack account or what you'd use for labs. If you don't know your password, you can set it on the SCS website: https://carleton.ca/scs/tech-support/accounts/ ## 5. Connect to the dev server *Do this step from inside VS Code* Back in VS Code, let's open the remote menu again: ![](https://i.imgur.com/AWnHRtK.png) Now we can "Connect to Host" and select the `ccss-summer-dev-projects` option. If you're connecting from Windows, it will prompt you about which operating system you're connecting to. You can select "Linux". (If on Windows platform VsCode: It may or may not prompt a continue window since the remote server has the fingerprint setup -> Just hit "Continue") ## 6. Test that Docker works *Do this step from inside VS Code while connected to the remote host* In a terminal on the dev server, try running `docker ps`. Something like the following should pop up: ![](https://i.imgur.com/qDRju15.png) ## 7. Add an SSH key to the dev server *Do this step from inside VS Code while connected to the remote host* We've already added an SSH key to our local machine, and used the public key on Github and the dev server. This is the key that lets us authenticate to these servers. We now need to create a second key on the dev server. To be clear, this **should not** be the same key as on your local computer. For this one, we'll also want to add a strong password. The reason for this is that the key will be accessible to the server owners, so protecting it with a password will keep it safe. In the terminal in VS Code, run the same command as before to add a key. Add a password when prompted. `ssh-keygen -t ed25519` and print it out with `cat ~/.ssh/id_ed25519.pub` If you need to re-create the password because you forgot it, you can just re-run the command. Finally, add this key to Github in the same way we did during step 2. Once you've added the key to Github, you'll need to set your name and email in the terminal: ``` git config --global user.name "Forest Anderson" git config --global user.email "forestkzanderson@gmail.com" ``` And switch the name/email for your name and your Github email address. ## 8. Test a dev container *Do this step from inside VS Code while connected to the remote host* We're going to clone a sample repo and open it in a dev container, then make sure we're able to connect to the Node server. In the terminal, clone the repository: `git clone git@github.com:CarletonComputerScienceSociety/students.carletoncomputerscience.ca.git` Then use `Ctrl+k+o` or `Cmd+o` and open the directory that was created in VS Code. You should now see a prompt to re-open this folder in dev containers in the bottom right. Click "reopen in container" ![](https://i.imgur.com/SoS4StG.png) Once the container loads, follow the instructions in the readme to start the server: ``` npm install npm run dev ``` ## Q&A -