In this lab I learned how to set my computer up for remote access to the CSE lab computers and practice with commands that work with the filesystem.
Visual Studio Code is a lightweight, open-source code editor that is easy to use and has a lot of features.
It is also cross-platform, meaning that it can be used on Windows, Mac, and Linux. It is also free to use, and has a lot of extensions that can be used to customize the editor to your liking.
You can find very clear installation instructions on VSCode website for the installation.
However, I often use package managers like brew on MacOS, or winget on windows to use less mouse action. So I will show you how to install VSCode using command line.
Currently, we do not need to use this code editor much. But in the future it helps a lot for programming as well as managing remote files in a very user-friendly way instead of the command line. It mean that it does not take a long time for any users to familiar with the UI and do not need to remember command line, which is often used by super-users.
# MacOS
brew install --cask visual-studio-code
# Windows
winget install -e --id Microsoft.VisualStudioCode
SSH stands for Secure Shell. It is a protocol that allows you to securely connect to a remote computer. It is a very common protocol that is used to connect to remote servers.
To connect to a remote computer, you need to know the IP address of the remote computer. You can find the IP address of the remote computer by running the following command:
ssh <username>@<ip-address>
In this course your <username>
will be cs15lfa22xx
, where xx
will be your code in this course. Where xx will be your code of course you could find it here. And <ip-address>
in this quarter is ieng6.ucsd.edu
.
Then a prompt will pop up asking for your password. Input your password and press Enter, the above connection to your remote computer will be connected.
The instruction on how to find, create, or reset passwords will be updated here.
Note: the username and password could be changed in the future. So please check with the professor for the latest information.
For example, my code will How to get your username in Fall 2022 as shown here by professor. This way may change in the future but looking at the structure could be helpful.
A few common commands to navigate and check directories. You can memorize it for faster action in the future.
Or play more with linux command line cheat sheet
If you have VSCode installed, moving files back and forth from your remote computer and your client computer is as simple as dragging and dropping or right-clicking and Download.
However, in case you work with a new or a stranger’s computer, this can be quite tricky. Below I will show you how to use scp
, a command to move files between your computer and the computer.
To move files from your computer to the remote computer, you can use the following command:
scp <file> <username>@<ip-address>:<destination>
Here is an example where I move a file of mine, which is named WhereAmI.java
from my laptop to cse computer on the home ~
directory remotely with scp
.
If you notice, on the example above I logged in wrongly 8 times with the reason that my password was too long.
I think you will also encounter the same situation in the future. To prevent that from happening, you can use the ssh-keygen
method to avoid using a password when making ssh connections to devices you trust.
# on client (your computer)
ssh-keygen
<Enter Password>
Just press enter until you see The key's randomart image is:
.
This will generate a public and private key pair. The public key will be stored in ~/.ssh/id_rsa.pub
and the private key will be stored in ~/.ssh/id_rsa
.
Now, we need to create a .ssh
directory on the remote computer and copy the public key to the remote computer.
# on server (remote computer)
mkdir ~/.ssh
<logout>
Back on client, copy the public key to the .ssh
folder that we created above.
# on client (your computer)
scp ~/.ssh/id_rsa.pub <username>@<ip-address>:~/.ssh/authorized_keys
Now, you can log in to the remote computer without a password.
In addition to using ssh-keygen to make the connection to the remote computer faster, there are some common commands, and shortcuts that you should keep in mind to move faster on the command window, such as:
Ctrl + A
to move to the beginning of the lineCtrl + E
to move to the end of the lineCtrl + U
to delete everything before the cursorCtrl + K
to delete everything after the cursorArrow Up
to move to the previous commandCombine commands together also makes using your command line much easier
Try to find out how to use these tasks in your command line:
&&
to combine two commands|
to pipe the output of one command to the input of another command>
to redirect the output of a command to a file