SSH Tutorial System Commands

System Commands
2 Mar 202421:16

Summary

TLDRThis tutorial provides a step-by-step guide on logging into a virtual machine using SSH keys for enhanced security, as password logins are disabled. It covers key generation on Linux, Unix, Mac, and Windows systems, including WSL, and demonstrates how to submit the public key for access. The video also navigates through the virtual machine to show how to read instructions, solve assignments, and use evaluation scripts to check and submit solutions, ensuring a comprehensive understanding of the process.

Takeaways

  • 🔑 You can no longer log into the virtual machine using passwords; SSH keys are now required for security.
  • 💻 For Linux, Unix, Mac, or Windows with WSL users, follow specific instructions to create SSH keys.
  • ⚙️ Use the 'ssh-keygen' command to generate a public and private key pair on your local system.
  • 🗂️ By default, the key files are stored in the home directory under the '.ssh' folder.
  • 🔑 The public key should be copied and uploaded to the server for authentication.
  • 🌐 Log into the specified website using your student email to submit the public key.
  • 💻 For Windows PowerShell users, different instructions are provided to generate and use SSH keys.
  • 📝 After generating the SSH keys, log into the virtual machine using the provided SSH command.
  • 📄 Always read the 'readme.md' file in the virtual machine for important instructions and assignment details.
  • 📂 Navigate to '/opt/se21' to find assignments, and use 'Synchro eval' to evaluate your solutions.

Q & A

  • Why can't I log into the virtual machine using passwords anymore?

    -Passwords are no longer used for logging into the virtual machine due to security measures. SSH keys are now the required method for accessing the virtual machine.

  • What are the prerequisites for logging into the virtual machine using SSH keys?

    -To log in using SSH keys, one must first create a pair of SSH keys (public and private) on their local system and then submit the public key to the server.

  • Can I use the same method to create SSH keys on both Linux/Unix/Mac and Windows?

    -The method for creating SSH keys is similar across Linux, Unix, Mac, and Windows with WSL. However, Windows users without WSL or using PowerShell will follow a slightly different process.

  • What command should I use to generate SSH keys on Linux or Unix?

    -On Linux or Unix, you can open a terminal and type 'ssh-keygen' to generate a public and private key pair.

  • What is the default location where the SSH keys are stored after creation?

    -By default, the SSH keys are stored in the '~/.ssh' directory of your home folder with the filenames 'id_rsa' for the private key and 'id_rsa.pub' for the public key.

  • Is it mandatory to set a passphrase for the SSH key?

    -Setting a passphrase for the SSH key is optional. It adds an extra layer of security, but for simplicity, it can be skipped by pressing enter when prompted.

  • How can I verify that my SSH keys have been created successfully?

    -You can verify the creation of SSH keys by navigating to the '~/.ssh' directory and using the 'ls' command to check for the presence of 'id_rsa' and 'id_rsa.pub' files.

  • What should I do with the public key after it's created?

    -The public key should be copied and pasted into the form provided on the server's website to allow you to log in to the virtual machine.

  • How do I log into the virtual machine for the first time using the SSH key?

    -After uploading the public key to the server, you can log in by using the command provided, which includes your role number and the server's address. The system will prompt you to trust the domain and then log you in automatically.

  • How can I navigate and solve assignments inside the virtual machine?

    -Inside the virtual machine, you should first read the 'readme.md' file for instructions. Assignments are located in '/opt/se21', and solutions should be written in a 'script.sh' file within a folder in your home directory corresponding to each assignment.

  • What command should I use to evaluate and submit my solution for an assignment?

    -To evaluate and submit your solution, you should use the 'synchro eval' command. It will provide feedback on the correctness of your script and confirm successful submission.

  • What is the purpose of the 'synchro eval' command in the context of the virtual machine?

    -The 'synchro eval' command is used to evaluate whether the script written for an assignment meets the requirements. It checks the script against predefined test cases and confirms if the submission is successful.

  • How can I make sure that my script is executable?

    -To make your script executable, you need to run the command 'chmod u+x script.sh' in the terminal, where 'script.sh' is the name of your script file.

  • What should I do if 'synchro eval' returns an evaluation fail?

    -If 'synchro eval' returns an evaluation fail, you should review the error message provided for clues on what might be wrong with your script. Common issues include the script not being executable or not meeting the assignment's requirements.

  • How can I view files with colors and in a paginated format?

    -You can use the 'bat' or 'cat' command followed by the name of the file to view files with colors. The output will be displayed in a paginated format for easier reading.

  • What is the recommended order for solving assignments and practice questions in the virtual machine?

    -The recommended order is to first solve the assignments in the order they are presented, and then proceed with the practice questions week by week, starting with the lowest numbered practice question and moving upwards.

Outlines

00:00

🔐 SSH Key Generation and Login to Virtual Machine

This paragraph introduces a tutorial on logging into a virtual machine using SSH keys, a security measure that replaces password logins. It outlines the process for creating SSH keys on Linux, Unix, Mac, and Windows systems, including Windows Subsystem for Linux (WSL). The tutorial demonstrates how to generate an RSA or ED25519 key pair, how to store and name the keys, and the optional pass phrase for encryption. It also explains how to copy the public key and submit it to the server to enable SSH login, followed by verification of successful login into the VM.

05:00

🖥️ Windows SSH Key Generation and VM Interaction

This section provides a tutorial for Windows users without WSL on generating SSH keys using PowerShell. It guides users through listing directory contents, generating keys, and using notepad to copy the public key. The process includes pasting the key into a portal for submission, and then using a command in PowerShell to log into the virtual machine. The tutorial also covers navigating the VM, reading the 'readme.md' file for instructions, and accessing and solving assignments within the VM environment.

10:01

📝 Assignment Completion and Evaluation in VM

The paragraph explains how to complete and evaluate assignments within the virtual machine. It details the process of reading the 'readme.md' file for task instructions, locating assignment directories, and writing scripts for solutions. The tutorial demonstrates creating a 'script.sh' file, making it executable, and using commands like 'sha256sum' and 'cut' to generate file hashes. It also shows how to use 'Synchro eval' to check the correctness of the script and submit it for evaluation.

15:02

🛠️ Script Development and Debugging in the VM

This paragraph focuses on script development and debugging for VM assignments. It describes the steps to create a script that takes a file name as an argument and prints its hash value using 'sha256sum'. The tutorial corrects a common mistake of hardcoding file names and instead uses '$1' to pass arguments to the script. It also emphasizes the importance of making scripts executable and using 'Synchro eval' to evaluate and submit assignments, providing feedback on script correctness and submission status.

20:02

📚 Navigating Assignments and Practice Questions

The final paragraph summarizes the process of navigating and completing assignments and practice questions in the VM. It advises on following the order of weeks for practice questions and tackling assignments in a comfortable sequence. The tutorial concludes by encouraging users to solve all assignments and explore the VM structure, ensuring a comprehensive understanding of the process.

Mindmap

Keywords

💡SSH keys

SSH keys are cryptographic credentials used for authenticating to servers and services securely without the need for passwords. In the video's context, SSH keys are essential for logging into the virtual machine provided for the course, emphasizing a security measure to prevent password-based logins. The script mentions creating an SSH key pair using the command 'ssh-keygen' and then submitting the public key to the server for access.

💡Security measure

A security measure refers to any action, process, or system designed to protect against threats or damage. In the video, the prohibition of password logins in favor of SSH keys exemplifies a security measure, aiming to enhance the protection of the virtual machine against unauthorized access.

💡Linux/Unix/Mac

These are operating systems that are typically used for their Unix-like environment, which is popular for development and system administration tasks. The tutorial differentiates instructions for users on these systems versus those using Windows, highlighting the diversity of user platforms and the need for platform-specific guidance in creating and using SSH keys.

💡Windows Subsystem for Linux (WSL)

WSL is a compatibility layer for running Linux binary executables natively on Windows. The script mentions WSL as an alternative for Windows users who wish to use Linux tools, such as those required for generating SSH keys, without needing a separate machine or virtual environment.

💡SSH keygen

SSH keygen is a command-line tool used to generate a pair of cryptographic keys for SSH authentication. In the video, 'ssh-keygen' is the command used to create the SSH key pair, which includes a private key kept secure on the user's machine and a public key that is shared with the server to enable secure login.

💡Public and private key pair

In cryptography, a public and private key pair are two distinct but mathematically linked keys. The private key is kept secret by the user, while the public key can be openly shared. In the script, the public key is uploaded to the server to authenticate the user's identity, while the private key is used on the user's end to decrypt the session.

💡Passphrase

A passphrase is a sequence of words or other text used to control access to a computer system, program, or physical device. In the context of SSH keys, a passphrase can be set to encrypt the private key, adding an additional layer of security. The video mentions the option to create a passphrase but suggests skipping it for simplicity.

💡SSH folder

The SSH folder is a directory on a user's system where SSH-related files, such as the generated key pairs, are typically stored. The video script refers to this folder when instructing users where to find the 'id_rsa' private key and 'id_rsa.pub' public key after they have been created.

💡Readme.md

Readme.md is a file often found in software repositories or project directories that provides important information about the project. In the video, 'readme.md' is highlighted as a crucial file to read first for instructions on how to proceed with tasks within the virtual machine, emphasizing the importance of understanding the project's requirements before starting work.

💡Synchro eval

Synchro eval appears to be a command or script used within the virtual machine to evaluate and submit assignments. The video describes using 'synchro eval' to check if the written script for an assignment is correct and to submit it for grading, indicating a system in place for automated assessment of student work.

💡Assignment

In the context of the video, an assignment refers to a task or project given to students as part of their coursework. The script discusses navigating to specific directories to find and work on assignments, such as 'assignment_0', and the process of creating and submitting solutions using 'script.sh' files.

Highlights

Introduction to logging into a virtual machine using SSH keys for enhanced security.

Demonstration of SSH key creation for Linux, Unix, Mac, and Windows users.

Explanation of the difference between SSH key types, such as RSA and ED25519.

Guidance on storing SSH keys in the default directory and the option to set a passphrase.

Instructions on copying the public SSH key for submission to the server.

Process of uploading the public key to the server via a specific website.

Tutorial on logging into the virtual machine using the SSH command.

Verification of successful login into the VM by checking the hostname.

Overview of navigating the virtual machine and accessing assignments.

Emphasis on reading the 'readme.md' file for important instructions before starting assignments.

Description of how to solve assignment zero, including using 'synchro eval' for evaluation.

Explanation of creating a script to calculate the hash value of a file using SHA-256.

Use of 'cut' command to format the output of the hash calculation.

Creating and making scripts executable for assignment submission.

Process of writing scripts for different assignments and using 'synchro eval' for correctness verification.

Importance of following the correct order of tasks in the assignments.

Encouragement to attempt assignments in a comfortable order and to explore the VM structure.

Conclusion of the tutorial with a thank you note and a prompt to complete all assignments.

Transcripts

play00:00

hello and welcome to this short tutorial

play00:02

on how to log in into the virtual

play00:03

machine provided by the system commands

play00:05

course using the SSH keys so you might

play00:08

already know that you cannot log into

play00:09

the virtual machine using passwords

play00:11

anymore so this has been done as a

play00:13

security measure and you can only log in

play00:14

using SSH keys so let us see how we can

play00:17

create the SSH keys and then submit the

play00:19

public key so that we can log in into

play00:20

the virtual machine so the first steps

play00:23

may be a little different depending on

play00:25

whether you're using Linux or Unix or

play00:27

Mac or whether you're using Windows so

play00:30

for the people who are using Linux or

play00:32

Unix or Mac or even using Windows with

play00:35

WSL or Windows subsystem for Linux and

play00:38

already have WSL set up they can follow

play00:42

these instructions whereas for people

play00:44

using only windows and po shell can

play00:46

follow these instructions instead so we

play00:48

will now be demonstrating both these

play00:51

methods one by one so let's start with

play00:52

the Linux way so now let's see how we

play00:55

can login into the VM without using a

play00:57

passwords so we are not allowed to login

play00:59

into to the system commands VM using

play01:01

passwords so what we have to do is we

play01:03

have to first create the public and

play01:05

private keypad using SSH keyen and then

play01:07

we have to copy the public key to the

play01:10

server so first open uh your local

play01:13

system so if you're using Windows you

play01:15

can use partion or if you're using Linux

play01:17

in your local system as well you can

play01:19

open any terminal and type this command

play01:22

ss- key so this will create a public and

play01:26

private key pair in your local system so

play01:29

you can give DD and RSA to specify what

play01:32

type of key you want so usually it will

play01:35

create RSA but if you're using a updated

play01:37

version of this command it will then

play01:39

create a Ed key so if you don't mention

play01:41

this it'll try to create a ed25519 key

play01:45

but if you want to let's say create an

play01:46

RSA key we can give DD RSA so this will

play01:50

ask you where you want to uh store the

play01:52

key so by default it stored in your uh

play01:55

own home directory inside the SSH folder

play01:58

and it is given a Name ID _ RSA so you

play02:02

can give a different name or a different

play02:04

path to this but by default this is the

play02:06

path which will be used so you can

play02:07

simply press

play02:09

enter and then it'll ask you for the

play02:11

pass phrase so this is optional you can

play02:14

give a pass phrase to this key so that

play02:15

the key is encrypted and when you want

play02:17

to use this key you will actually have

play02:18

to give this pass phrase again but for

play02:20

Simplicity let's skip this step and just

play02:22

press enter here so we again press enter

play02:25

and our private and public key is now

play02:27

created and it's saved in the/ home /y

play02:30

your username SSH and then idore RSA is

play02:33

your private key and idore R.P is your

play02:37

public key so this public key is

play02:39

something which you share to others and

play02:40

which you will upload to the server so

play02:43

the first step is to first see now that

play02:45

whether the keys is created or not so

play02:47

let us cut out the key and see if it's

play02:48

created so we'll go to the SSH folder

play02:51

and C out the idore

play02:53

R.P and as you can see the public key is

play02:55

now created so I can simply copy this

play02:57

key from here by selecting it and

play03:00

pressing control shift C if you're in uh

play03:02

Linux terminal or if you're on Windows

play03:04

partial you can right click and copy

play03:07

another way you can copy if you're on

play03:08

Linux is you can use the xclip or the

play03:10

xell

play03:12

command so this will put it into your

play03:15

clipboard then we open this website

play03:17

which is se2000 1. ds. study. i. ac.in

play03:22

and here we have to log in with our itm

play03:24

student email ID so just select your

play03:27

student email ID and and then you will

play03:30

be redirected to this page where you

play03:33

will be asked to create the SSH key so

play03:36

these are the exact steps which we took

play03:38

to create this uh SSH key so once it's

play03:40

created you can then copy the key public

play03:42

key from the location and then you have

play03:45

to paste it in this form so simply paste

play03:49

it from your clipboard and the key

play03:51

should usually start with ssh-rsa or s-

play03:55

Ed and the username will be autofill so

play03:58

you have to Simply press the sub it and

play04:00

the public key is now uploaded into the

play04:03

server so now you can log in into the

play04:05

server using the commands given here as

play04:08

such Your Role number at se21 ds. study.

play04:12

it. ac.in so let's see if we can log

play04:15

into this server so we copy this command

play04:17

and we open a teral again and we simply

play04:20

have to paste this here so the first

play04:22

time you are doing this it'll also ask

play04:24

you if you want to save this and do you

play04:26

trust this domain so you have to Simply

play04:27

type yes and press enter and after that

play04:30

it will automatically log you in so as

play04:33

you can see now we are logged into the

play04:35

VM and you can verify this by echoing

play04:37

the host name so the host name is se21

play04:41

so on your system your host name will be

play04:42

whatever is your devices name but once

play04:45

you have S into it you are now inside

play04:46

the VM and you will get the se21 as the

play04:50

host name you can also see who is the

play04:52

account holder in which you're logged in

play04:54

so that will be your register number so

play04:57

that's all you need to do to log into

play04:58

the VM

play05:00

now let's see how we can do the same

play05:01

thing if you're using Windows without

play05:04

WSL so you will follow the following

play05:06

instructions let us see a demo now yeah

play05:08

this is a short tutorial on how to do

play05:10

SSX using windows power shell type LS to

play05:12

see the files and folders present in

play05:14

your directory right now type SSH hyen

play05:17

key genexe and then press enter to

play05:20

generate SSH keys there is no need to

play05:23

type anything just press enter again

play05:26

once again yeah type LS uh as you can

play05:30

see there is a new folder created SSH

play05:33

let's go into the folder cd. SSH enter

play05:38

LS type

play05:40

notepad.exe

play05:43

space idore rs. puuv and then press

play05:48

enter notepad just pop up copy the

play05:52

following

play05:53

line go to the

play05:58

portal as scroll

play06:01

down paste the line press

play06:07

submit copy the

play06:09

line go to the power

play06:12

shell observe the prompt which is right

play06:15

now in white color paste the command

play06:17

which you have just copied right now and

play06:20

then press

play06:22

enter just type

play06:26

S as you can see the prompt has changed

play06:28

from white color to Green color that

play06:30

means you are right now in the virtual

play06:31

Mission you can execute some of the

play06:33

commands here if you

play06:35

want PWD present working directory

play06:40

LS cat the following

play06:45

file after once you have done your work

play06:47

you can type exit

play06:52

exit observe the last line log out

play06:55

connection to SC 2001. ds. study. in

play06:59

close which means you just exited from

play07:01

the

play07:02

VM thank you all right so hopefully now

play07:05

I have successfully logged into the

play07:06

virtual machine so let us see how we can

play07:08

navigate inside the virtual machine and

play07:10

how we can also view the assignments and

play07:12

solve the assignments inside the virtual

play07:13

machine so the first and foremost thing

play07:16

you should do is read the readme.md file

play07:18

so MD is a markdown file so readme file

play07:20

is a file which stores all the important

play07:23

instructions one should read first

play07:25

before proceeding so you can find the

play07:27

read me file inside your home directory

play07:29

as well as inside the /opt SE 20001

play07:33

directory so once you have read the

play07:35

readme file you will understand how to

play07:37

do the basic tasks inside the virtual

play07:39

machine let us quickly demonstrate how

play07:40

we can solve the assignment

play07:43

zero so right now in my local system let

play07:46

me SSH into my virtual machine so I have

play07:49

to provide my register number and then

play07:51

give a at and then type se2000 1. ds.

play07:55

study. m.

play07:58

ac.in once you have provided the public

play08:00

key in the website successfully this

play08:02

will automatically log you in so as you

play08:03

can see the prompt will now be like this

play08:05

it will be your roll number at se and

play08:08

you can also confirm that you are inside

play08:10

the virtual machine using Echo host name

play08:12

and should say

play08:14

se21 now let us see how we can solve the

play08:18

assignments first we can catch the

play08:20

readme.md and if you want we can instead

play08:23

of cat we can use bat cat so that will

play08:26

print it with

play08:28

colors so here we can see that each

play08:30

assignment's question will be found in

play08:31

/opt se21 and then the name of the

play08:34

folder so it will be assignment _ 0

play08:37

assignment _ one Etc and the solution

play08:39

which you will have to write to submit

play08:41

has to be present in your home directory

play08:44

and then a folder se21 and then the name

play08:46

of the folder so once you have written

play08:49

the script and you are confident with it

play08:51

you have to type Synchro eval to

play08:53

evaluate whether your answer is correct

play08:55

or not so if it's correct you will get

play08:56

these two lines evaluation successful

play08:58

submission successful

play08:59

if you do not get the evaluation

play09:01

successful just uh try to see where your

play09:03

code might be wrong and then rewrite the

play09:05

code and then again do Synchro

play09:08

EV so there are other FAQs you can read

play09:11

from here so you can use batcat as we

play09:13

doing instead of cat to display some

play09:15

files with the colors and in a paginated

play09:18

format and you can also use t-mo to

play09:20

Multiplex your sessions so that you can

play09:21

have multiple applications open inside

play09:24

one

play09:26

SSH so let us now see where we can find

play09:28

the questions so as you can see in your

play09:30

home directory you will have a read me

play09:32

file only and nothing else and the path

play09:34

of this home directory is/ home/ your RO

play09:36

number so now where we want to go

play09:38

instead is/ opt

play09:41

se21 so now you can see the path has

play09:43

been changed in our prompt and also cuty

play09:45

will show that path now if you do LS you

play09:47

can see there are multiple questions so

play09:49

these are all the questions that you can

play09:51

solve so the assignment ones are the FM

play09:53

assignments and the practice ones are

play09:54

the practice questions for each week so

play09:57

let us see to how we can solve

play09:58

assignment _ 0 and the same process will

play10:01

follow for all of the else as

play10:03

well so if we now enter inside

play10:06

assignment Z so here we can see the path

play10:09

is now /opt se2 1/ assignment _ 0 so I

play10:13

can clear the screen using clear and

play10:15

here you can see there are multiple

play10:16

files so let me go over each file one by

play10:18

one so the evaluation file. sh or the

play10:21

evaluation script is a file which

play10:23

contains the script which will actually

play10:25

evaluate whether your script which you

play10:27

write is correct or not so you can see

play10:29

how that is there so if you're let's say

play10:31

stuck you can see how the evaluation

play10:33

script is written to understand why it

play10:35

may not be working so we can see the

play10:37

evaluation script has some code which

play10:40

evaluates whether our script which is

play10:41

supposed to be script.sh is working

play10:45

correctly or not so we don't actually

play10:47

have to do anything into the evaluation

play10:48

script we should not try to change it so

play10:50

even if we do it won't be possible

play10:52

because we are not authorized to access

play10:55

this so we can only read it but we

play10:57

cannot remove it so if I try to remove

play10:58

this it will give me a permission error

play11:01

because we are not permitted to do

play11:03

this for each assignment the first thing

play11:05

you should do is print the readme.md so

play11:09

this will tell you exactly what you have

play11:10

to do so as you can see the readme.md

play11:13

says that this is the Z VM task and this

play11:15

is not graded and this already has the

play11:17

solution provided to us so this again

play11:20

reiterates that you have to use Synchro

play11:21

eval to

play11:23

evaluate so what we have to do now is we

play11:25

have to create a script called script.sh

play11:28

and we have to store it inside our home

play11:30

directory so this is currently in/ opt

play11:33

se21 but we have to create a folder

play11:35

called se21 in our home directory and

play11:37

inside there we have to name it

play11:40

assignment undor z a folder and then in

play11:42

that folder we have to create a

play11:43

script.sh so for all of these

play11:46

assignments and create practice

play11:47

questions we have to create a folder for

play11:48

each of them similarly how they are

play11:49

created here in our home directory and

play11:52

in that file we have to do the following

play11:54

tasks so the task is the file takes a

play11:56

file name as an argument and print the

play12:00

hash value of that file name so let us

play12:03

try to see how we can do that so we also

play12:05

have a example file here hello.txt and

play12:08

we are told that this file's uh output

play12:11

from the script should be this one so

play12:14

let us see how we can do this so there

play12:16

are multiple ways to create a hash so a

play12:19

few of them are the Sha or s a hash

play12:23

there are also something called MD hash

play12:25

and there are also other hashes so these

play12:27

sha and MD are already pre-installed in

play12:29

Linux so you can simply type MD sum or

play12:33

md5 sum and then give it a file name to

play12:35

get a hash so as you can see the md5 sum

play12:38

gives us a hash but this is not the same

play12:40

as this one and this is shter so md5 is

play12:42

usually outdated now and no longer used

play12:44

because the hashes are small and people

play12:46

now have a pretty good database of what

play12:49

each hash means so instead we will use

play12:52

the

play12:54

shahash so to use the shahash we have to

play12:57

see which shahash we want so there are

play12:59

multiple sha hashes so if you type sha

play13:01

and press tab twice you can see there is

play13:03

sha 1 sha 2 24 sha 2 56 sha 384 sha 512

play13:08

sums and what the number means is

play13:10

basically the number of bits so the more

play13:12

the number of bits the longer the key

play13:14

will be and also the more secure it will

play13:16

be so let us see which sha matches with

play13:18

this one so if I do sha one sum

play13:22

hello.txt you can see the number is not

play13:25

the same and it's also smaller so let's

play13:27

try with sha 5 112 sum and now you can

play13:30

see the number is still different but

play13:32

it's way longer than what is expected so

play13:35

let us now test with sha 256 sum and now

play13:38

you can see that the text is matching

play13:40

exactly so it's 133 e e and then it's

play13:42

sing with 2D 44 and the length is also

play13:44

exactly the same so we have now

play13:46

understood that we need to use sha 256

play13:48

sum and pass the file name to get the

play13:52

Sha but this also gives a space and then

play13:56

the name of the text itself so there are

play13:58

multiple ways in which we can only get

play14:00

the

play14:02

text so let us see now how we can

play14:05

instead of having the name of the file

play14:07

we can have just the hash and nothing

play14:10

else so we can use a command called as

play14:13

cut which helps us to trim away some

play14:16

parts of a line so in this case we want

play14:18

to cut with the space delimeter so as

play14:20

you can see there are two spaces here so

play14:21

I want to cut with the delimeter of

play14:23

space so I give space inside quotations

play14:26

to the- D flag which uh Tak which delim

play14:29

should cut by and then I ask the cut

play14:32

command to print only the first field

play14:33

which is till the number four and this

play14:36

will then only print the hash till the

play14:38

number and nothing from the first space

play14:41

so this is now exactly what we want but

play14:43

instead of the hello.txt we want the

play14:46

name of the file to be given to the

play14:47

script so let us now create the script

play14:51

but the script has to be created in our

play14:53

home directory so as you can see we are

play14:55

currently in/ opt se21 SL assignment

play14:58

zero whereas we need to be in our home

play15:01

so if I just type CD and press enter I

play15:03

will now be back into my home and here

play15:05

you can see we do not have the se21

play15:07

folder so the simplest way is we can

play15:10

simply just copy this folder into our

play15:13

home as well so I can do

play15:15

cpop

play15:16

se21 and name it here as home/

play15:21

se21 and because we are copying

play15:23

directories and not single file we have

play15:25

to give the- R flag which means that

play15:27

copy the folders

play15:29

recursively all right so now if I do LS

play15:31

you can see that there is a folder named

play15:33

se21 and if I go inside there we have

play15:36

all the assignments as we saw earlier so

play15:38

let us CD into assignment

play15:40

zero and we can see that for the

play15:43

assignment Z we already have the script

play15:44

given to us because this is a solved

play15:46

assignment but let me remove the script

play15:48

for now and write it

play15:49

ourselves so the first thing which we

play15:51

have to do is we have to open create the

play15:53

file using either Vim or Nano any editor

play15:56

you

play15:57

want so once we are inside the file we

play16:00

have to write the command which will

play16:02

give us the output so before writing the

play16:04

command what we do is we preface the

play16:05

file by mentioning which type of script

play16:07

this is so we do this by writing hash

play16:09

and then exclamation mark this is called

play16:11

shibang and then we give the path of The

play16:14

Interpreter which will run this so for

play16:16

our case this is been

play16:18

bash and here we will write the command

play16:21

which will give us the output so as we

play16:23

saw earlier what we can do is we can use

play16:24

sha 256 sum and the name of the file and

play16:28

then we can use cut to basically cut the

play16:31

space and then give us the first field

play16:32

from the space so if I save this and

play16:37

exit so that we can do by first of all

play16:38

exiting the insert mode by pressing

play16:40

escape and then I can press colon and

play16:42

then WQ so w means right and Q mean

play16:45

squid so now you can see we have the

play16:47

script.sh but still this will not work

play16:49

because the script by default will be

play16:51

not executable so we can make it

play16:53

executable by running CH mod u+ x and

play16:57

the name of the file so this is

play16:59

something you will have to do for everyd

play17:00

assignment once you have created the

play17:01

script.sh file you should also CH mode

play17:03

and make it executable so now we can see

play17:06

that the script is now executable so

play17:08

there's an X here and also the file is

play17:10

now shown in green marking that it is an

play17:12

executable file so let me run script.sh

play17:15

and you can see this is giving us the

play17:16

expected output however this is usually

play17:20

not what is asked from the code so if I

play17:23

if we just open the read me again we can

play17:26

see that a script should take any file

play17:28

name as an argument and print the hash

play17:30

of that file so ideally what should

play17:32

happen is if I give hello.txt it should

play17:34

print this but if I print give it some

play17:36

other file it should print the hash of

play17:38

that instead so if I let's say give it

play17:41

readme.md it should print me the hash of

play17:43

readme.md so right now it's printing

play17:45

still the hatch of

play17:47

hello.txt that is because in our script

play17:50

what we have done is we have hardcoded

play17:51

the text hello.txt instead what we need

play17:53

to do is we need to pass whatever was

play17:55

passed as the first argument as the

play17:57

argument to to the shash sum so what we

play18:00

can do is we can instead of this we can

play18:02

add dollar one and dollar one basically

play18:04

means the first argument given to this

play18:07

script so dollar 0 will be the name of

play18:09

the script itself dollar one the first

play18:10

and dollar two the second argument Etc

play18:13

so now if I exit the script again and

play18:17

now if I run this I'll get a different

play18:19

hash but if I run this with hello do txt

play18:23

we still get the original hash for the

play18:24

hello so this is now the correct script

play18:27

and we have also checked it with the

play18:29

hello.txt so if you remember the read me

play18:32

had the correct value of that which

play18:33

starts with 133 e and even uh script is

play18:37

giving the same output so now this is

play18:39

just us writing the script but not

play18:40

submitting it for us to evaluate it

play18:42

whether it's correct or not and whether

play18:43

it's right and then to submit it what we

play18:46

can do is we can type Synchro eval and

play18:49

now this will tell us that the public

play18:50

test case evaluation successful private

play18:52

disc case submission successful so this

play18:54

means that aspt was correct and it has

play18:56

been successfully submitted so this has

play18:58

has been now marked in the database that

play19:00

you have completed this question so

play19:01

similarly you can then go back and you

play19:04

can go into the other assignments so

play19:06

let's say assignment one and you can

play19:08

read the read

play19:09

me and you can see what you have to do

play19:12

for the other assignments also and

play19:13

create the script.sh in that folder

play19:15

again and then once you have written the

play19:17

script correctly you can run Synchro

play19:18

eval again and then check if it's

play19:21

correct so because we don't have the

play19:22

script for this assignment it'll give us

play19:24

an evaluation fail because we have not

play19:26

written the script so let me quickly

play19:28

write script for assignment one and see

play19:30

if it works all right so I have gone

play19:33

ahead and created the script.sh I will

play19:35

obviously not show what is inside

play19:36

because this is a greated assignment but

play19:39

now let us see what happens if we run

play19:40

Synchro eval so we are getting a

play19:43

evaluation field and this is because we

play19:44

can also get a helpful error message

play19:46

which tells us why it's not working so

play19:48

it's telling us that it is not

play19:49

executable so we have obviously

play19:51

forgotten to make it executable so what

play19:53

we can do is we can do CH modu plus X

play19:55

script.sh and then run it again and now

play19:58

you can see that the evaluation is

play19:59

successful because the script which is

play20:01

present here is correct and it is doing

play20:03

what is asked to do so now we can also

play20:07

see that the files are also present in

play20:09

the diory S1 doxt s2. txt s3. txt and S4

play20:11

dxt according to the read me so now this

play20:15

tells us that the evaluation is

play20:16

successful and the submission is also

play20:17

successful so this is basically how you

play20:19

have to do all of these assignments so

play20:21

you can go over each of them one by one

play20:23

and do the ones which you feel are easy

play20:25

and then try to do the ones which are

play20:27

harder than the previous ones so the

play20:29

practice ones are week wise so if you're

play20:31

doing week two make sure you're doing

play20:33

also the practice 2.1 2.2 2.3 2.4 2.5

play20:36

2.6 2.7 2.8 2.9 and 2.10 so the order in

play20:41

which it's shown may not be correct so

play20:43

it may show 2.1 and then 2.0 but uh

play20:45

ideally you should do it like 1 2 3 4

play20:48

you can also mix and match obviously

play20:49

whichever you feel is easier you can do

play20:50

earlier so there's no order you have to

play20:52

follow but the first number is the

play20:53

number of week in which it should be

play20:56

done and the assignments are the task

play20:58

assignments so you can do them also in

play21:00

order or you can do them in any order

play21:01

you find comfortable so that was it for

play21:04

this tutorial so hopefully you are able

play21:06

to now SSH into the VM and also have

play21:08

explored how the VM is structured and

play21:10

how everything is present

play21:12

everywhere so just try to solve all

play21:14

these assignments thank you

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
SSH KeysVirtual MachineLogin TutorialLinuxMacWindowsSecurityKey GenerationITM StudentsSystem Commands
هل تحتاج إلى تلخيص باللغة الإنجليزية؟