Open main menu

CDOT Wiki β

Changes

Tutorial6: File Transfer / Sending Email Messages

214 bytes added, 09:26, 29 January 2020
INVESTIGATION 2: USING SECURE FILE TRANSMISSION CONTROL PROTOCOL
# Change to the '''~/local''' directory.<br><br>
# Use a text editor to create a text file called '''thefile.txt'''<br><br>
# Enter the following two lines displayed belowfor this text file:<br><span style="font-family:courier;font-weight:bold;">This is my file called thefile.txt<br>It is also a small file</span><br><br># '''Save ''' editing changes to the text files and exit your text editor.<br><br># Change back to your '''home''' directory and confirm that you are located in your ''home'' directory.<br><br>Let's run a '''shell script''' to check to make certain that you created the correct directories<br>and that you created the '''myfile.txt''' file (with correct file contents) in the '''~/local''' directory<br>in order before learning to practice using use the ''scpsftp'' Linux command.<br><br># Issue the following Linux command to run a checking script: <br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/scripts/week6-check-3</span><br><br># Issue the following Linux command to start an sftp session (i.e. note: yoursenecaid is YOUR Seneca ID):<br><span style="color:blue;font-weight:bold;font-family:courier;">sftp yoursenecaid@matrix.senecacollege.ca</span><br><br>'''NOTE:''' You may be required to enter '''yes''' to have the public key shared.<br><br>You are now in the '''sftp command prompt''' where you are expected to issue '''sftp commands'''.<br>Please refer to the table of ''sftp commands '' in the '''KEY CONCEPTS''' section for reference.<br><br># Issue the following ''sftp command'': <span style="color:blue;font-weight:bold;font-family:courier;">pwd</span><br><br>What is the pathname? Which server does this represent: local or remote?<br><br># Issue the following ''sftp command'': <span style="color:blue;font-weight:bold;font-family:courier;">!pwd</span><br><br>What is the pathname? Which server does this represent: local or remote?<br><br># Issue the following ''sftp command '' to create a directory on your remote server: <span style="color:blue;font-weight:bold;font-family:courier;">mkdir remote</span><br><br># Issue the following ''sftp command '' to confirm that the '''remote''' directory has been created in your remote server's home directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">ls</span><br><br># Issue the following ''sftp command '' to change to the '''remote''' directory on your remote server:<br><span style="color:blue;font-weight:bold;font-family:courier;">cd remote</span><br><br># Issue the '''pwd''''' sftp command '' to confirm that you have changed to the ''remote2'' directory on your remote server.<br><br>
# Issue the following sftp command to change to the '''local''' directory on your local server:<br><span style="color:blue;font-weight:bold;font-family:courier;">lcd local</span><br><br>
# Issue the '''pwd''''' sftp command '' to confirm that you have changed to the ''local'' directory on your local server.<br><br># Issue the following Linux ''sftp command '' to transfer your '''~/local/thefile.txt ''' file to the '''~/remote ''' directory on your remote server:<br><span style="color:blue;font-weight:bold;font-family:courier;">put thefile.txt</span><br><br># Issue the '''ls''' sftp command to confirmed that you transferred/copied the file: thefile.txt<br><br>Let's create another directory on your local server called storage '''local2''' so we can learn to <u>download </u> a file from your remote directory.<br><br># Issue the following Linux ''sftp command '' (without an argument) to change to your '''home ''' directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">lcd</span><br><br># Issue the '''!pwd''' ''sftp command '' to confirm that your current working directory on your local server is your home directory.<br><Br># Issue the following Linux ''sftp command '' to create the following directory on your local server:<br><span style="color:blue;font-weight:bold;font-family:courier;">mkdir local2</span><br><br># Issue the following Linux ''sftp command '' to change to the '''local2''' directory on your local server:<br><span style="color:blue;font-weight:bold;font-family:courier;">lcd local2</span><br><br># Issue the !pwd ''sftp command '' to confirm you have changed to the ''local2'' directory on your local server.<br><br>Let's learn to download a file from your remote server to your local server.<br><br># Issue the following Linux '''sftp command ''' to transfer your '''thefile.txt ''' file from your remote directory on your local server:<br><span style="color:blue;font-weight:bold;font-family:courier;">get thefile.txt</span><br><br># Issue the '''!ls''' ''' sftp command ''' to confirmed confirm that you transferred/copied the file: thefile.txt on your local server.<br><br># Issue the following ''sftp command '' to exit the sftp utlilty: <span style="color:blue;font-weight:bold;font-family:courier;">exit</span><br><br>
# Issue the following Linux command to confirm that you are back in your original server: <span style="color:blue;font-weight:bold;font-family:courier;">hostname</span><br><br>Let's run a shell script to see if you correctly transferred/copied files between your local and remote servers.<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-4</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 learn an alternative way to transfer a file to another computer server by sending an e-mail message with an attached file.
13,420
edits