Changes

Jump to: navigation, search
INVESTIGATION 1: USING SECURE COPY
</tr>
</table><br><br>
<ol><li value="3">When you have issue the above ssh command, enter your password to login.<br><br></li><li>Issue the following Linux commands to create the following directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">mkdir ~/remote</span><br><br></li><li>Change to the <b>~/remote</b> directory and confirm that you have changed to that directory.<br><br></li><li>Use a text editor to create a text file called <b>myfile.txt</b><br><br></li><li>Enter the following two lines displayed below in your editing session:<br><span style="font-family:courier;font-weight:bold;">This is my file<br>It is a small file</span><br><br></li><li><b>Save</b> editing changes to your ''myfile.txt'' file and exit your text editor.<br><br></li><li>Change back to your <b>home</b> directory and confirm that you are located in your <i>home</i> directory.<br><br></li><li>Let's run a <b>shell script</b> to check that you created the correct directories<br>and that you created the <b>myfile.txt</b> file (with correct file contents) in the <b>~/from</b> directory<br>before using the ''scp'' Linux command.<br><br></li></li>Issue the following: <span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts/week6-check-1</span><br><br></li><li>If you encounter errors, make corrections and then re-run the checking script until you receive<br>a congratulations message, and proceed to the next step.<br><br><b>NOTE:</b> We will now learn to transfer files between your <b>(local) home computer</b> and your <b>(remote) Matrix Linux server</b>.<br><br></li><li>Exit your Matrix ssh session, but remain in the OS terminal on your <u>home</u> computer.<br><br></li><li>The <b>mkdir</b> command works with <i>MS Windows/UNIX/Linux/MacOSx computers</i>.<br>Issue the following command to create a directory called <b>local</b> in your current directory: <span style="color:blue;font-family:courier;font-weight:bold;">mkdir local</span><br><br></li><li>The <b>cd</b> command works with <i>MS Windows/UNIX/Linux/MacOSx computers</i>.<br>Issue the following command to change to the local directory: <span style="color:blue;font-family:courier;font-weight:bold;">cd local</span><br><br></li><li>If you are in MS Windows, open the <span style="color:blue;font-family:courier;font-weight:bold;">NotePad</span> application to create a text file.<br><br><b>NOTE:</b> if you are using a Graphical Linux or MacOSx OS, then use a text editor like <b>vi</b><br>.</li><li>Enter a few lines of text, and then click on the <b>File</b> menu and select <b>save as</b> (save as the filename <b>other.txt</b>)<br>and then <b>exit</b> the <i>Notepad</i> text editor.<br><br></li><li>If your OS is MS Windows issue the <span style="color:blue;font-family:courier;font-weight:bold;">dir</span> to confirm the contents of your current directory<br>(otherwise, issue the <b>ls</b> command for other operating systems).<br><br>The <b>SSH package</b> on your <i>home computer</i> and on the <i>Matrix Linux server</i> contain a <b>suite</b> (i.e. <b>collection</b>) of secure utilities <br>including <b>ssh</b>, <b>scp</b> and <b>sftp</b>.<br><br></li><li>Issue the following Linux command to copy the <b>other.txt</b> file from your local machine to your remote Matrix server<br>(replace yoursenecaid is <u>YOUR</u> Seneca ID and ADD A COLON : TO THE END OF THE COMMAND):<br><span style="color:blue;font-weight:bold;font-family:courier;">scp other.txt yoursenecaid@matrix.senecacollege.ca:</span><br><br></li><li>When prompted, enter your Matrix '''password'''.<br><br><b>TIP:</b> You can issue the ssh command, followed by a command that will be run on your remote computer,<br>but displayed on your local computer <b><u>without</u></b> having to establish a continuous connection to your remote Matrix server.<br><br></li><li>Issue the following command (using your matrix username): <span style="color:blue;font-weight:bold;font-family:courier;">ssh yoursenecaid@matrix.senecacollege.ca ls -l</span><br><br></li><li>When prompted, enter your password and press ENTER.<br><br>Do you see detailed information regarding the file called <b>output.txt</b>?<br>That command was run remotely on your Matrix server as confirmation that you securely copied that file<br>to the home directory of the Matrix server.<br><br></li><li>Issue the following command to copy that same file to the ~/remote directory in Matrix:<br><span style="color:blue;font-weight:bold;font-family:courier;">scp other.txt yoursenecaid@matrix.senecacollege.ca:remote</span><br><br></li><li>Issue the following command to confirm that it was remotely copied to your ~/remote directory in Matrix:<br><span style="color:blue;font-weight:bold;font-family:courier;">ssh yoursenecaid@matrix.senecacollege.ca ls -l /home/yoursenecaid/remote</span><br><br>Do you see the output for the detailed file listing of <b>output.txt</b>?<br>What does this indicate?<br><br>Let's issue a checking script remotely to see that you properly copied that file from your local computer to your remote Linux server to both your <b>home</b> directory and <b>~/remote</b> directory.<br><br></li><li>Issue the following:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts/week6-check-2</span><br><br>If you encounter errors, re-run the scp commands to correct and re-run the above command until you receive a congratulations message.<br><br></li></ol>
 
# Issue the '''ls''' command for the home directory.<br><br>What do you see?<br>What does this tell you about how the previously-issued command works with just a colon?<br><br>
# Issue the following Linux command (leaving-out the colon character at the end): <br><span style="color:blue;font-weight:bold;font-family:courier;">scp myfile.txt yoursenecaid@matrix.senecacollege.ca</span><br><br>What happened? (hint: look for a file named: '''yoursenecaid@matrix.senecacollege.ca''').<br><br>
# Make certain that your current directory is your '''home''' directory.<br><br>
# Issue the following Linux command to run a checking script to ensure you created the CORRECT directories, created and copied the correct files: <br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts/week6-check-2</span><br><br>
# If you encounter errors, make corrections and then re-run the checking script until you receive a congratulations message.<br><br>
:In the next investigation, you will use the '''sftp''' Linux command to transfer (i.e. copy) files between servers.<br><br>
12,768
edits

Navigation menu