SSH Tutorial System Commands
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
🔐 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.
🖥️ 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.
📝 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.
🛠️ 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.
📚 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
💡Security measure
💡Linux/Unix/Mac
💡Windows Subsystem for Linux (WSL)
💡SSH keygen
💡Public and private key pair
💡Passphrase
💡SSH folder
💡Readme.md
💡Synchro eval
💡Assignment
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
hello and welcome to this short tutorial
on how to log in into the virtual
machine provided by the system commands
course using the SSH keys so you might
already know that you cannot log into
the virtual machine using passwords
anymore so this has been done as a
security measure and you can only log in
using SSH keys so let us see how we can
create the SSH keys and then submit the
public key so that we can log in into
the virtual machine so the first steps
may be a little different depending on
whether you're using Linux or Unix or
Mac or whether you're using Windows so
for the people who are using Linux or
Unix or Mac or even using Windows with
WSL or Windows subsystem for Linux and
already have WSL set up they can follow
these instructions whereas for people
using only windows and po shell can
follow these instructions instead so we
will now be demonstrating both these
methods one by one so let's start with
the Linux way so now let's see how we
can login into the VM without using a
passwords so we are not allowed to login
into to the system commands VM using
passwords so what we have to do is we
have to first create the public and
private keypad using SSH keyen and then
we have to copy the public key to the
server so first open uh your local
system so if you're using Windows you
can use partion or if you're using Linux
in your local system as well you can
open any terminal and type this command
ss- key so this will create a public and
private key pair in your local system so
you can give DD and RSA to specify what
type of key you want so usually it will
create RSA but if you're using a updated
version of this command it will then
create a Ed key so if you don't mention
this it'll try to create a ed25519 key
but if you want to let's say create an
RSA key we can give DD RSA so this will
ask you where you want to uh store the
key so by default it stored in your uh
own home directory inside the SSH folder
and it is given a Name ID _ RSA so you
can give a different name or a different
path to this but by default this is the
path which will be used so you can
simply press
enter and then it'll ask you for the
pass phrase so this is optional you can
give a pass phrase to this key so that
the key is encrypted and when you want
to use this key you will actually have
to give this pass phrase again but for
Simplicity let's skip this step and just
press enter here so we again press enter
and our private and public key is now
created and it's saved in the/ home /y
your username SSH and then idore RSA is
your private key and idore R.P is your
public key so this public key is
something which you share to others and
which you will upload to the server so
the first step is to first see now that
whether the keys is created or not so
let us cut out the key and see if it's
created so we'll go to the SSH folder
and C out the idore
R.P and as you can see the public key is
now created so I can simply copy this
key from here by selecting it and
pressing control shift C if you're in uh
Linux terminal or if you're on Windows
partial you can right click and copy
another way you can copy if you're on
Linux is you can use the xclip or the
xell
command so this will put it into your
clipboard then we open this website
which is se2000 1. ds. study. i. ac.in
and here we have to log in with our itm
student email ID so just select your
student email ID and and then you will
be redirected to this page where you
will be asked to create the SSH key so
these are the exact steps which we took
to create this uh SSH key so once it's
created you can then copy the key public
key from the location and then you have
to paste it in this form so simply paste
it from your clipboard and the key
should usually start with ssh-rsa or s-
Ed and the username will be autofill so
you have to Simply press the sub it and
the public key is now uploaded into the
server so now you can log in into the
server using the commands given here as
such Your Role number at se21 ds. study.
it. ac.in so let's see if we can log
into this server so we copy this command
and we open a teral again and we simply
have to paste this here so the first
time you are doing this it'll also ask
you if you want to save this and do you
trust this domain so you have to Simply
type yes and press enter and after that
it will automatically log you in so as
you can see now we are logged into the
VM and you can verify this by echoing
the host name so the host name is se21
so on your system your host name will be
whatever is your devices name but once
you have S into it you are now inside
the VM and you will get the se21 as the
host name you can also see who is the
account holder in which you're logged in
so that will be your register number so
that's all you need to do to log into
the VM
now let's see how we can do the same
thing if you're using Windows without
WSL so you will follow the following
instructions let us see a demo now yeah
this is a short tutorial on how to do
SSX using windows power shell type LS to
see the files and folders present in
your directory right now type SSH hyen
key genexe and then press enter to
generate SSH keys there is no need to
type anything just press enter again
once again yeah type LS uh as you can
see there is a new folder created SSH
let's go into the folder cd. SSH enter
LS type
notepad.exe
space idore rs. puuv and then press
enter notepad just pop up copy the
following
line go to the
portal as scroll
down paste the line press
submit copy the
line go to the power
shell observe the prompt which is right
now in white color paste the command
which you have just copied right now and
then press
enter just type
S as you can see the prompt has changed
from white color to Green color that
means you are right now in the virtual
Mission you can execute some of the
commands here if you
want PWD present working directory
LS cat the following
file after once you have done your work
you can type exit
exit observe the last line log out
connection to SC 2001. ds. study. in
close which means you just exited from
the
VM thank you all right so hopefully now
I have successfully logged into the
virtual machine so let us see how we can
navigate inside the virtual machine and
how we can also view the assignments and
solve the assignments inside the virtual
machine so the first and foremost thing
you should do is read the readme.md file
so MD is a markdown file so readme file
is a file which stores all the important
instructions one should read first
before proceeding so you can find the
read me file inside your home directory
as well as inside the /opt SE 20001
directory so once you have read the
readme file you will understand how to
do the basic tasks inside the virtual
machine let us quickly demonstrate how
we can solve the assignment
zero so right now in my local system let
me SSH into my virtual machine so I have
to provide my register number and then
give a at and then type se2000 1. ds.
study. m.
ac.in once you have provided the public
key in the website successfully this
will automatically log you in so as you
can see the prompt will now be like this
it will be your roll number at se and
you can also confirm that you are inside
the virtual machine using Echo host name
and should say
se21 now let us see how we can solve the
assignments first we can catch the
readme.md and if you want we can instead
of cat we can use bat cat so that will
print it with
colors so here we can see that each
assignment's question will be found in
/opt se21 and then the name of the
folder so it will be assignment _ 0
assignment _ one Etc and the solution
which you will have to write to submit
has to be present in your home directory
and then a folder se21 and then the name
of the folder so once you have written
the script and you are confident with it
you have to type Synchro eval to
evaluate whether your answer is correct
or not so if it's correct you will get
these two lines evaluation successful
submission successful
if you do not get the evaluation
successful just uh try to see where your
code might be wrong and then rewrite the
code and then again do Synchro
EV so there are other FAQs you can read
from here so you can use batcat as we
doing instead of cat to display some
files with the colors and in a paginated
format and you can also use t-mo to
Multiplex your sessions so that you can
have multiple applications open inside
one
SSH so let us now see where we can find
the questions so as you can see in your
home directory you will have a read me
file only and nothing else and the path
of this home directory is/ home/ your RO
number so now where we want to go
instead is/ opt
se21 so now you can see the path has
been changed in our prompt and also cuty
will show that path now if you do LS you
can see there are multiple questions so
these are all the questions that you can
solve so the assignment ones are the FM
assignments and the practice ones are
the practice questions for each week so
let us see to how we can solve
assignment _ 0 and the same process will
follow for all of the else as
well so if we now enter inside
assignment Z so here we can see the path
is now /opt se2 1/ assignment _ 0 so I
can clear the screen using clear and
here you can see there are multiple
files so let me go over each file one by
one so the evaluation file. sh or the
evaluation script is a file which
contains the script which will actually
evaluate whether your script which you
write is correct or not so you can see
how that is there so if you're let's say
stuck you can see how the evaluation
script is written to understand why it
may not be working so we can see the
evaluation script has some code which
evaluates whether our script which is
supposed to be script.sh is working
correctly or not so we don't actually
have to do anything into the evaluation
script we should not try to change it so
even if we do it won't be possible
because we are not authorized to access
this so we can only read it but we
cannot remove it so if I try to remove
this it will give me a permission error
because we are not permitted to do
this for each assignment the first thing
you should do is print the readme.md so
this will tell you exactly what you have
to do so as you can see the readme.md
says that this is the Z VM task and this
is not graded and this already has the
solution provided to us so this again
reiterates that you have to use Synchro
eval to
evaluate so what we have to do now is we
have to create a script called script.sh
and we have to store it inside our home
directory so this is currently in/ opt
se21 but we have to create a folder
called se21 in our home directory and
inside there we have to name it
assignment undor z a folder and then in
that folder we have to create a
script.sh so for all of these
assignments and create practice
questions we have to create a folder for
each of them similarly how they are
created here in our home directory and
in that file we have to do the following
tasks so the task is the file takes a
file name as an argument and print the
hash value of that file name so let us
try to see how we can do that so we also
have a example file here hello.txt and
we are told that this file's uh output
from the script should be this one so
let us see how we can do this so there
are multiple ways to create a hash so a
few of them are the Sha or s a hash
there are also something called MD hash
and there are also other hashes so these
sha and MD are already pre-installed in
Linux so you can simply type MD sum or
md5 sum and then give it a file name to
get a hash so as you can see the md5 sum
gives us a hash but this is not the same
as this one and this is shter so md5 is
usually outdated now and no longer used
because the hashes are small and people
now have a pretty good database of what
each hash means so instead we will use
the
shahash so to use the shahash we have to
see which shahash we want so there are
multiple sha hashes so if you type sha
and press tab twice you can see there is
sha 1 sha 2 24 sha 2 56 sha 384 sha 512
sums and what the number means is
basically the number of bits so the more
the number of bits the longer the key
will be and also the more secure it will
be so let us see which sha matches with
this one so if I do sha one sum
hello.txt you can see the number is not
the same and it's also smaller so let's
try with sha 5 112 sum and now you can
see the number is still different but
it's way longer than what is expected so
let us now test with sha 256 sum and now
you can see that the text is matching
exactly so it's 133 e e and then it's
sing with 2D 44 and the length is also
exactly the same so we have now
understood that we need to use sha 256
sum and pass the file name to get the
Sha but this also gives a space and then
the name of the text itself so there are
multiple ways in which we can only get
the
text so let us see now how we can
instead of having the name of the file
we can have just the hash and nothing
else so we can use a command called as
cut which helps us to trim away some
parts of a line so in this case we want
to cut with the space delimeter so as
you can see there are two spaces here so
I want to cut with the delimeter of
space so I give space inside quotations
to the- D flag which uh Tak which delim
should cut by and then I ask the cut
command to print only the first field
which is till the number four and this
will then only print the hash till the
number and nothing from the first space
so this is now exactly what we want but
instead of the hello.txt we want the
name of the file to be given to the
script so let us now create the script
but the script has to be created in our
home directory so as you can see we are
currently in/ opt se21 SL assignment
zero whereas we need to be in our home
so if I just type CD and press enter I
will now be back into my home and here
you can see we do not have the se21
folder so the simplest way is we can
simply just copy this folder into our
home as well so I can do
cpop
se21 and name it here as home/
se21 and because we are copying
directories and not single file we have
to give the- R flag which means that
copy the folders
recursively all right so now if I do LS
you can see that there is a folder named
se21 and if I go inside there we have
all the assignments as we saw earlier so
let us CD into assignment
zero and we can see that for the
assignment Z we already have the script
given to us because this is a solved
assignment but let me remove the script
for now and write it
ourselves so the first thing which we
have to do is we have to open create the
file using either Vim or Nano any editor
you
want so once we are inside the file we
have to write the command which will
give us the output so before writing the
command what we do is we preface the
file by mentioning which type of script
this is so we do this by writing hash
and then exclamation mark this is called
shibang and then we give the path of The
Interpreter which will run this so for
our case this is been
bash and here we will write the command
which will give us the output so as we
saw earlier what we can do is we can use
sha 256 sum and the name of the file and
then we can use cut to basically cut the
space and then give us the first field
from the space so if I save this and
exit so that we can do by first of all
exiting the insert mode by pressing
escape and then I can press colon and
then WQ so w means right and Q mean
squid so now you can see we have the
script.sh but still this will not work
because the script by default will be
not executable so we can make it
executable by running CH mod u+ x and
the name of the file so this is
something you will have to do for everyd
assignment once you have created the
script.sh file you should also CH mode
and make it executable so now we can see
that the script is now executable so
there's an X here and also the file is
now shown in green marking that it is an
executable file so let me run script.sh
and you can see this is giving us the
expected output however this is usually
not what is asked from the code so if I
if we just open the read me again we can
see that a script should take any file
name as an argument and print the hash
of that file so ideally what should
happen is if I give hello.txt it should
print this but if I print give it some
other file it should print the hash of
that instead so if I let's say give it
readme.md it should print me the hash of
readme.md so right now it's printing
still the hatch of
hello.txt that is because in our script
what we have done is we have hardcoded
the text hello.txt instead what we need
to do is we need to pass whatever was
passed as the first argument as the
argument to to the shash sum so what we
can do is we can instead of this we can
add dollar one and dollar one basically
means the first argument given to this
script so dollar 0 will be the name of
the script itself dollar one the first
and dollar two the second argument Etc
so now if I exit the script again and
now if I run this I'll get a different
hash but if I run this with hello do txt
we still get the original hash for the
hello so this is now the correct script
and we have also checked it with the
hello.txt so if you remember the read me
had the correct value of that which
starts with 133 e and even uh script is
giving the same output so now this is
just us writing the script but not
submitting it for us to evaluate it
whether it's correct or not and whether
it's right and then to submit it what we
can do is we can type Synchro eval and
now this will tell us that the public
test case evaluation successful private
disc case submission successful so this
means that aspt was correct and it has
been successfully submitted so this has
has been now marked in the database that
you have completed this question so
similarly you can then go back and you
can go into the other assignments so
let's say assignment one and you can
read the read
me and you can see what you have to do
for the other assignments also and
create the script.sh in that folder
again and then once you have written the
script correctly you can run Synchro
eval again and then check if it's
correct so because we don't have the
script for this assignment it'll give us
an evaluation fail because we have not
written the script so let me quickly
write script for assignment one and see
if it works all right so I have gone
ahead and created the script.sh I will
obviously not show what is inside
because this is a greated assignment but
now let us see what happens if we run
Synchro eval so we are getting a
evaluation field and this is because we
can also get a helpful error message
which tells us why it's not working so
it's telling us that it is not
executable so we have obviously
forgotten to make it executable so what
we can do is we can do CH modu plus X
script.sh and then run it again and now
you can see that the evaluation is
successful because the script which is
present here is correct and it is doing
what is asked to do so now we can also
see that the files are also present in
the diory S1 doxt s2. txt s3. txt and S4
dxt according to the read me so now this
tells us that the evaluation is
successful and the submission is also
successful so this is basically how you
have to do all of these assignments so
you can go over each of them one by one
and do the ones which you feel are easy
and then try to do the ones which are
harder than the previous ones so the
practice ones are week wise so if you're
doing week two make sure you're doing
also the practice 2.1 2.2 2.3 2.4 2.5
2.6 2.7 2.8 2.9 and 2.10 so the order in
which it's shown may not be correct so
it may show 2.1 and then 2.0 but uh
ideally you should do it like 1 2 3 4
you can also mix and match obviously
whichever you feel is easier you can do
earlier so there's no order you have to
follow but the first number is the
number of week in which it should be
done and the assignments are the task
assignments so you can do them also in
order or you can do them in any order
you find comfortable so that was it for
this tutorial so hopefully you are able
to now SSH into the VM and also have
explored how the VM is structured and
how everything is present
everywhere so just try to solve all
these assignments thank you
5.0 / 5 (0 votes)