Instructor: Hello.
In this lesson, we are going to cover SCP,
which is secure copy protocol.
Now, the secure copy protocol, or SCP,
helps to transfer computer files securely
from a local host to a remote host.
It is somewhat similar to FDP,
but it adds security and authentication.
So if you are transferring a file, again,
from server A to server B, you could use SCP as the protocol
or the command rather than FTP.
And the reason it is preferred is because it is secure,
it adds more security and authentication.
Now the protocol, as I said before,
the protocol is a set of rules
used by computers to communicate.
So when the SCP was built, they decided,
okay, this is the protocol that SCP should use,
and this is the port that should be used
to transfer a file from one server to another.
The default SCP port is SSH or port 22.
So there is no different protocol
that was established or set up for SCP,
so it actually leverages onto the same SSH protocol
that we use to connect
from one server to another, or SSH.
Now, for this lecture, again, we need two Linux machines.
One is for the client and one is for the server.
The client is where we have the file,
and the server is where we want to transfer that file to.
For the client, I have my Linux machine,
and it is called MyFirstLinuxVM.
For the server, I have a server
which is exactly the same as client as well,
but I named it LinuxCentOS7.
So the process is, this SCP,
the process in the graphical way
is you have a client A and client B server.
Now, client A wants to copy a file over to server B.
Now, it will use the protocol SCP or the command SCP,
but it actually transferred that over through
the protocol we already have in place, and that is SSH.
So there is no new protocol for that.
It actually piggybacked on SSH.
And of course, the SSH port is 22,
and the service for SSH daemon should be running
under recipient or the remote server
in order to accept incoming traffic.
Okay, what's the process?
The SAP command to transfer files to the remote server.
First of all, you have to log in yourself.
Then create a file, any file.
Let's say we, in this lesson or in this lab,
we'll create a file called Jack.
Once the Jack file is created,
then we will simply run the command SCP,
the filename Jack.
Iafzal is a username that actually exists
on the remote server at 192 168 1.x
is the actual IP of the remote server.
Of course, replace that X with the digit.
That is the digit of your remote server.
And the last part is :/home/iafzal.
This is where you want the file to go to,
in this directory on the remote server.
Once it's connected, then it's gonna ask you
to enter username and password,
and it will transfer the file successfully.
Now, enough is enough.
Let's actually start our Linux machine,
which I have already started
and I have already logged in through my PuTTY.
This is my Linux machine,
and I refer to as my client machine
because this is the one that connects to the server.
And this machine host name is My First Linux VM.
Who is logged in?
Who am I?
I'm logged in as myself.
If I follow the directions here,
I'm gonna create a file called Jack in my home directory,
my home directory, /home/iafzal.
I'll go ahead and do touch, Jack,
and I do ls - ltr.
You'll see I have a file called Jack.
It has zero bytes.
Now, I wanted to transfer that, but before I transfer it,
put something in there just to make sure
it is transferred with the right content.
So let's do vi on Jack,
and just put Jack as
Jerry's uncle.
That's it.
DOS-LTR, now you'll see it has total by 22.
Perfect.
Now we need to transfer this file to our remote server.
But before we transfer that file to the remote server,
we wanted to know what is the IP address
of that remote server.
So I'm gonna go into my remote server,
which I also have it open,
and I'm going to do if config enp0x3,
because that's the interface where the IP is assigned.
And the IP is 192 168 1.58.
Beautiful.
Please use IPA command if you are on a newer version
of Red Hat or CentOS system.
Let's go back to my client,
and now this time I'm going to run the command.
Let's clear the screen so you could see it better.
Now run the command SCP,
the name of the file, which is Jack,
the name of the user
who is going to log in to the remote server.
What is the remote server?
192.168.1.
58
Yes.
And then colon, slash where is it going to,
or which directory it's going to, home iafzal.
Hit enter, and it's gonna ask you for the password.
If you are doing SAP for the first time,
then it's gonna ask you for the fingerprints
where you have to type in yes,
and then enter the password.
So go ahead and enter password.
And it says Jack, which is the file name,
100% transferred, and the size was 22,
and this is the time it took to transfer.
Okay, I got this message on the client,
but let's confirm on the server whether it
was transferred or not.
So first of all, it was transferred as iafzal,
so I have to log in as iafzal.
So who am I?
I am iafzal.
Beautiful.
Now, which directory am I logged into?
I am in my home directory
because that's where I transferred the file, right?
Now I will do LS-LTR
to check if that Jack file came in.
It did.
Perfect.
Is this the right file that came in?
Let's cat it.
We did the cat, Jack is Jerry's uncle.
Perfect.
This is how the SCP works.
And you could also do the same thing, by the way,
SCP to go into this remote server
if you wanted to pull something out of that server
from server to the client,
and you have just have to reverse the command.
Anyway, try it out.
And these are the couple of commands,
a few commands that I wanted to cover,
and very important commands
when you are dealing with transferring files
from one server to another.