ieng6
server.Step 1. Install Visual Studio Code
Note: This is an important step as having VSCode installed will make it easier for us to see what is going on as we write our webpage. In VSCode, we are able to see the outcome of whatever we are writing (left-hand side) on the right-hand size; like a split screen. We can identify any mistakes early on by having an image of what we are writing.
To download VSCode, navigate to the Official VSCode Website. Follow the instructions for a successful download. Once downloaded, your screen should look like this once you launch the application:
Step 2. Remotely Connecting to Another Server
$ ssh cs15lfa22<>@ieng6.ucsd.edu
. You shouldn’t write the <>
in there, it is just a placeholder–you need to know what your CSE15L account is for this step.
Congratulations! You have successfully connected to a remote server! :)
Step 3. Trying out Commands
In this part, we will be trying out some commands on our newly connected account.
ls -lat
command:
ls -a
, which will also show all files, without any timestamps or dates:
Finally, running the cat /home/linux/ieng6/cs15lfa22/public/hello.txt
command will print out the contents of the hello.txt file:
which is a small welcome to the course!
Now you know how to run commands on a remote server! :D
Step 4. Moving Files with the scp
Command
WhereAmI.java
, with the following contents:
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"));
}
}
Before compiling and running the file, type exit
onto the terminal to exit the remote account.
javac
and java
commands.
scp
command in order to copy the file, as shown below:
scp WhereAmI.java cs15lfa22zz@ieng6.ucsd.edu:~/
Note: The scp
command stands for “Secure Copy Protocol,” and it does just that: securely copies a file from one host to the other, remotely.
ssh
command, which will ensure a safe file transfer to our remote account:
ssh
command and we compile and run the WhereAmI.java
file, we will get more information about our current remote account, as running these commands has printed out the OS, the name of the account, and even the directory of that account.We just successfully copied a file from one computer to another remotely! :D
Step 5: Using an SSH key
ssh
key. More specifically, the command is ssh-keygen
. We will be using this very useful command in order to diminish the time it takes for us to completely log in remotely and when using scp
, as we repeatedly have to be typing in our password everytime.ssh-keygen
will do is fairly simple: it creates a pair of files, the “public key” and the “private key,” and then the public key is copied to a particular location on the server, while the private key gets copied to a particular location on the client. After this, using the ssh
command with this key already in place will allow us to use those files (the public and private keys) instead of our password.$ ssh-keygen
Which should bring up something like this afterwards:
PS C:\Users\Viann\OneDrive\Documents\GitHub\cse15l-lab-reports> ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Viann/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Viann/.ssh/id_rsa.
Your public key has been saved in C:\Users\Viann/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:YGLAwtiIYQWR6me7yce/Q4tLLR8HLUGkjO9gk1ieOsY viann@DESKTOP-LCQR4P1
The key's randomart image is:
+---[RSA 3072]----+
|=O*. .o |
|*oo.o o |
|.. oooo. |
|. +.+o .o |
|.. B . oS. |
|..oo+ ..o |
| Eo o+oo.. |
|. o.o+ooo |
| +o.o+o |
+----[SHA256]-----+
id_rsa
, and the public key, which is in the file id_rsa.pub
, all stored in the .ssh
directory on our computer..ssh
directory of our user account on the server. To do this, write out the following in your terminal:# on your client
$ ssh cs15lfa22<>@ieng6.ucsd.edu
(type out your password)
Note: the <> is a placeholder for the last two letters on your account.
# now on the server
$ scp /Users/your name/.ssh/id_rsa.pub cs15lfa22@ieng6.ucsd.edu:~/.ssh/authorized_keys
(Note: use your username and the path you saw from the command above)
Once you do this, you should be able to ssh
or scp
from this client to the server without entering your password.
Note: I will not be showing my screenshots for this part since I unfortunately couldn’t get this to work for some reason, as I kept getting asked for my password when doing the scp
part, and everytime I typed it out, it kept prompting me to keep inputing it.
Step 6: Attempting for Remote Running to be even More Pleasant
WhereAmI.java
, copying it to the remote server, and running it.ssh
command to directly run it on the remote server, and then exit. As an example, running this command will list the home directory on the remote server:
$ ssh cs15fa22@ieng6.ucsd.edu "ls"
$ scp WhereAmI.java OtherMain.java; javac OtherMain.java; java WhereAmI
Please note: as mentioned previously, I was unable to get my ssh
part working from the previous step, which also prevented me from completing this step.