Installing VS Code
This is MacOS version downloaded and opened.
Remotely Connecting
You can connect the remote server by ssh (The Secure Shell)
ssh cs15lfa22zz@ieng6.ucsd.edu
(with zz replaced for correct username)If it is first time logging in, it could ask “Are you sure you want to continue connecting (yes/no/[fingerprint])?” question.
After successful login, temrminal is now connected to the server.
It will show status like below image.
Trying commands
There are multiple commands that could be used in the terminal.
These are few examples of commands.
When it is run in terminal, it would look like this.
Moving file with
scp
class WhereAmI {
public static void main(String[] args) {
System.out.println(System.getProperty("os.name"));
System.out.println(System.getProperty("user.name"));
System.out.println(System.getProperty("user.home"));
System.out.println(System.getProperty("user.dir"));
}
}
It will print like this below
scp WhereAmI.java cs15lfa22zz@ieng6.ucsd.edu:~/
Notice that WhereAmI.java file is added in the directory.
Also different username and os name is printed depending if the java file was run in computer or server.
Setting an SSH key
When logging into the server, it is difficult to enter password everytime. To make this easiler, there is SSH key.
ssh-keygen
in the computer terminalIt will look like below.
ssh cs15lfa22zz@ieng6.ucsd.edu
and log inmkdir .ssh
in the serverscp /Users/(username)/.ssh/id_rsa.pub cs15lfa22zz@ieng6.ucsd.edu:~/.ssh/authorized_keys
After this, password is not required when logging into the server.
Optimizing remote running
There is easiler way to make a copy of a file and run in the remote server by semicolon and quotes.
Multiple commands can be run in same line with semicolon.
Quotes at the end of the ssh
allows to run command.
scp WhereAmI.java cs15lfa22zz@ieng6.ucsd.edu"~/
to copy the file to the serverssh cs15lfa22zz@ieng6.ucsd.edu "javac WhereAmI.java; java WhereAmI"