Hello, in this lesson we are going to
cover SCP, which is Secure Copy
Protocol. 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 FTP, 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 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 setup
for SCP. So it actually leverages on to
the same SSH protocol that we use to
connect from one server to another over
SSH. Now, for this lecture, again, we
needed 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 had named it
LinuxCentOS7. So the process is
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 piggybacks
on SSH. And of course, the SSH port is
22. And the service where SSH daemon
should be running on the recipient or
the remote server in order to accept incoming traffic.
Okay, what's the process? The SCP 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 file named jack, iafzal is the
user name that actually exists on the
remote server, @, 192.168.1.x
is the actual IP of
the remote server. Of course, we
replace that x with the digit that is
the digit of your remote server, and the
last part is colon slash home slash 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
going to 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 into 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 hostname is MyFirstLinuxVM.
Who is logged in? whoami, I'm logged in
as myself. Alright follow the directions
here. I'm going to create a file called
jack in my home directory, in my home
directory slash home slash iafzal.
I'll go ahead and do touch jack. When I do
ls -ltr, you will see I have a
file called jack, it has zero bytes. Now
I want to transfer that but before I
transfer it, let's 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 is Jerry's Uncle. That's it.
Let's do ls -ltr. Now you see, it
has total bytes 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 their remote server.
So I'm going to go into my remote
server, which I also have opened. And
I'm going to do ifconfig enp0s3
because that's the interface
where the IP is assigned, and the IP is
192.1681.58. Beautiful. 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.56, yes, and
then colon slash, where is it going to
or which directory, it is going to /home/iafzal.
hit enter, and it's going to ask you
for the password. If you are doing SCP
for the first time, then it's going to
ask you for the fingerprints where you
have to type in yes, and then enter the
password. So go ahead and password. And
it says a jack, which is a 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 whoami, 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. Now 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 want 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.
[No audio]