13,420
edits
Changes
→INVESTIGATION 1: USING SECURE COPY
</tr>
</table><br><br>
<ol><li value="3">When you have issue the '''ssh''' command to connect to After logging into your Matrix serveraccount, enter your password to login.<br><br></li><li>Issue 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>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>Enter the following command: <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'''.<br><br><span style="color:blue;">'''ATTENTION:''' You are <u>REQUIRED</u> to open a terminal on your <u>local</u> (Windows/MacOSx/Linux) computer.<br>Do <u>'''NOT'''</u> use the ''ssh'' command to connect to your Matrix account.<br><br></li><li>The <b>mkdir</b> command works with <i>MS Windows/UNIX/Linux/MacOSx computers</i>.<br>Issue the following command on your <u>local</u> computer to create a directory called <b>local</b>: <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 on your <u>local</u> computer to change to the <b>local</b> directory: <span style="color:blue;font-family:courier;font-weight:bold;">cd local</span><br><br></li><li>If you are using MS Windows on your local computer, issue the <span style="color:blue;font-weight:bold;font-family:courier;">dir</span> command to confirm you are<br>in the ''local'' directory; otherwise, use the <span style="color:blue;font-weight:bold;font-family:courier;">ls -ld</span> command.<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 if using '''Notepad''', then click on the <b>File</b> menu and select <b>save as</b><br>(save as the filename <b>other.txt</b> in your <b>local</b> directory) and then <b>exit</b> the <i>Notepad</i> text editor.<br><br>Otherwise, if using another text editor, save your editing session and exit the 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> Windows command to view the contents of your current directory<br>(otherwise, issue the <span style="color:blue;font-family:courier;font-weight:bold;">ls</span> command for other operating systems).<br><br>We will now use the scp command to copy the <u>local</u> file called '''other.txt''' to your home directory on your <u>remote</u> Matrix Linux server.<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 other.txt</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>other.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>Use the '''Notepad''' application (or vi for other OS types) to create a text file called '''mytextfile.txt'''<br>and save in the '''local''' directory of your computer.<br><br></li>
<li>Issue the following Linux command to copy the <b>mytextfile.txt</b> file from your local machine to your remote Matrix server<br>(replace yoursenecaid is <u>YOUR</u> Seneca ID and DO <u>NOT</u> INCLUDE THE : at the end of the command so see what happens):<br><span style="color:blue;font-weight:bold;font-family:courier;">scp mytextfile.txt yoursenecaid@matrix.senecacollege.ca</span><br><br>Did you notice anything different?<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 mytextfile.txt</span><br><br></li><li>When prompted, enter your password and press ENTER.<br><br>Do you see the file? That is because the COLON was NOT added to the end of the command!<br><b>Therefore, you MUST remember to include the COLON : at the end of the hostname, or it will NOT properly remotely copy the file!</b><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><li>Issue the following command to copy the '''other.txt''' file to the ~/remote directory in Matrix renaming it is '''different.txt''':<br><span style="color:blue;font-weight:bold;font-family:courier;">scp other.txt yoursenecaid@matrix.senecacollege.ca:remote/different.txt</span><br><br></li><li>Issue the following command to confirm that the file was remotely copied to your '''~/remote''' directory in Matrix with a different filename:<br><span style="color:blue;font-weight:bold;font-family:courier;">ssh yoursenecaid@matrix.senecacollege.ca ls -l /home/yoursenecaid/remote/different.txt</span><br><br>What does this indicate?<br><br>Let's issue a checking script remotely to see that you properly copied that file from your<br>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;">ssh yoursenecaid@matrix.senecacollege.ca 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><li>Remain in the terminal on your local computer for the ''INVESTIGATION 2''.<br><br></ol>