1
00:00:00,000 --> 00:00:17,600
Hey everyone and welcome back. So in the previous nugget we had talked about our SSH client

2
00:00:17,600 --> 00:00:24,480
configuration. We also discussed how SSH can be used to ultimately wrap things like FTP

3
00:00:24,480 --> 00:00:31,679
so that the regular unsecured FTP can now be transported using encryption. So how about we

4
00:00:31,679 --> 00:00:37,120
dive in and begin getting hands on then shall we? So what I will do here is if I clear the screen here

5
00:00:37,120 --> 00:00:43,920
in fact let me just change the size right here. So we have server one and on the right here we

6
00:00:43,920 --> 00:00:50,799
have server two. Let me clear the screen on that. There we go. So as we know we already can SSH from

7
00:00:50,799 --> 00:00:57,919
one server into the next. So again if I try to SSH from server two and I go into the IP address

8
00:00:57,919 --> 00:01:05,120
of number one which is 4.26. We can type in the password bam we're in who am I and we can see

9
00:01:05,120 --> 00:01:11,359
we are in server one. No problem at all and no big revelation at all. So if we close the connection

10
00:01:11,359 --> 00:01:18,239
now what I want to first do is to show you how we can actually use something called secure copy to

11
00:01:18,239 --> 00:01:25,039
ultimately copy files from one server to the other and have that transaction be securely

12
00:01:25,039 --> 00:01:30,640
encrypted so that any potential e-droppers could not actually see what the data that is being

13
00:01:30,640 --> 00:01:36,479
passed between the servers actually is. So check this out then. What I will do here is let's maybe

14
00:01:36,479 --> 00:01:42,479
go on to server one then. So on server one we can see here I'm in my home directory. I can do an ls.

15
00:01:42,480 --> 00:01:48,159
Now if I want to just create a particular file let's maybe put it in I don't know let's just go

16
00:01:48,159 --> 00:01:55,439
for the documents directory. So cd into the docs we do an ls. We do not have any particular file

17
00:01:55,439 --> 00:02:01,760
here what I will do is I will actually create a file. So I'll just call this maybe my personal

18
00:02:02,320 --> 00:02:11,680
stuff.txt okay. Just say this is some personal file on server one. Okay so let's save you write it out

19
00:02:11,680 --> 00:02:17,599
and escape if we cat this particular file we can see we have the contents here. What I now want to

20
00:02:17,599 --> 00:02:26,480
do is I want to be able to take this file right here and move it into server two and again I want

21
00:02:26,480 --> 00:02:34,000
this transaction to be encrypted over ssh. So what I'm going to do here is I'm going to use the scp

22
00:02:34,000 --> 00:02:41,840
command. Now the syntax is going to be as follows. I'm going to say on my server one where the actual

23
00:02:41,840 --> 00:02:49,759
file resides. I'm going to say scp and then I'm going to specify the file which I want to copy now

24
00:02:49,759 --> 00:02:55,599
the absolute path and the relative path is still in play here because I happen to be within. Again

25
00:02:55,599 --> 00:03:01,759
I show you here the documents directory where this file resides. I can just specify the name of the

26
00:03:01,759 --> 00:03:08,560
file otherwise if I was in a different location I would have to specify the absolute path for that

27
00:03:08,560 --> 00:03:13,439
particular file but like I say we're in this directory so no need I will just specify the

28
00:03:13,439 --> 00:03:18,319
name of the file and you know what let me just get a little bit more real estate here and now what I

29
00:03:18,319 --> 00:03:25,359
want to do is I want to specify where it is I want to send this so I'm going to log in to

30
00:03:25,440 --> 00:03:32,320
server two here so the ip address or rather the username should I say to log in with is ipv0 because

31
00:03:32,320 --> 00:03:39,600
that is the user here on server two and I'm going to use server two's ip address which is 1921684.28

32
00:03:40,880 --> 00:03:45,600
now what I'm going to do is have a colon and a forward slash and now what I have to do is specify

33
00:03:46,240 --> 00:03:53,600
where abouts in that server do I want to copy this file so if I go into server two what I could do

34
00:03:53,599 --> 00:03:58,560
is let's just say I wanted to copy it to let's maybe say the downloads directory it doesn't have

35
00:03:58,560 --> 00:04:04,319
to be here you can copy it anywhere you wish but the point is here is the actual path okay so what I

36
00:04:04,319 --> 00:04:10,719
can do here is actually just specify this path here so I can say home and we can see it's ipv0 so

37
00:04:10,719 --> 00:04:18,639
I'll just say ipv0 and the directory I'm going to put this into is the downloads directory okay now if

38
00:04:18,639 --> 00:04:26,560
I just hit enter here we can see the banner right here I'm going to type in my password for server two

39
00:04:27,120 --> 00:04:32,959
hit enter now we can actually see this is the file that has been copied over and we can see 100%

40
00:04:33,599 --> 00:04:39,839
and a little summary of the connection crucially though if I go into this directory which I am

41
00:04:39,839 --> 00:04:46,319
and I do an ls now notice this file exists on this server and we can actually cut this by opening it

42
00:04:46,319 --> 00:04:52,159
there we go this is some personal file on server one but now it's been copied to server two now there

43
00:04:52,159 --> 00:04:57,120
are a few variations which you can use within here for example let's just do the same thing I'll do an

44
00:04:57,120 --> 00:05:03,680
ls in fact an ls would be helpful and I just remove this file so it's no longer on the server

45
00:05:03,680 --> 00:05:09,439
let's say I wanted to copy it once again now what I can do here is if I clear the screen back on server

46
00:05:09,439 --> 00:05:16,319
one and I arrow up if I just specify the name of the directory the file is going to be copied with

47
00:05:16,319 --> 00:05:22,879
the same name however if within this directory I just give it a new name if I just call this let's

48
00:05:22,879 --> 00:05:30,159
just say bladot txt and I hit enter again type in the password for server number two hit enter

49
00:05:30,159 --> 00:05:36,800
the connection happened again we can see the summary we have sent this file but notice this time in

50
00:05:36,800 --> 00:05:42,800
this directory here on server two the file is called bladot txt it was renamed but the contents

51
00:05:42,800 --> 00:05:48,800
are exactly the same similarly we can also still make use of again I'll just remove this one more

52
00:05:48,800 --> 00:05:55,759
time so we don't have it we can also make use of our variables so what do I mean as opposed to having

53
00:05:55,759 --> 00:06:03,199
to specify home ipv0 what I could do is I could just delete this and I could use my dollar sign home

54
00:06:03,199 --> 00:06:10,399
pretty much saying that just copy this directly to that server's home directory and again if I

55
00:06:10,399 --> 00:06:15,920
wanted to rename it I could just say whatever I wanted to rename it rename dot txt doesn't matter

56
00:06:15,920 --> 00:06:22,639
for now I'll just leave it at the home directory so if I hit enter and just do my password

57
00:06:23,360 --> 00:06:29,120
enter again again we've transferred that file once again if I do a pwd we're in the wrong

58
00:06:29,120 --> 00:06:34,879
directory so I'll change directory into the home where we are I do an ls and now we can see on server

59
00:06:34,879 --> 00:06:41,199
two once again that file has indeed been transferred and again a stress this has been transferred using

60
00:06:41,199 --> 00:06:49,759
ssh and fully encrypted now with scp we do have more options more switches if I do a man scp right

61
00:06:49,759 --> 00:06:55,840
here if I just scroll on down we can see some different options we have we can use ip4 addresses

62
00:06:55,839 --> 00:07:02,560
we can just use ipv6 we can specify particular ports to target we can preserve modification

63
00:07:02,560 --> 00:07:08,079
times and access times from the original file which can be very useful we can also say dash v

64
00:07:08,079 --> 00:07:14,959
for for bose mode we can do dash q to dampen the output and have a quiet mode so just one last time

65
00:07:14,959 --> 00:07:21,120
what I'll do is I will do scp and I'll use a particular switch let's just say dash v for verbose

66
00:07:21,120 --> 00:07:25,120
this time I'll put it in the user's home directory but I'll rename the file let's just say

67
00:07:25,680 --> 00:07:31,439
blad2.txt and that that matters if I hit enter look at the information that has just been

68
00:07:31,439 --> 00:07:37,199
splashed onto the screen much much more verbose as we expect so if I type in the password one more

69
00:07:37,199 --> 00:07:43,360
time hit enter we can see the connection right here the transfer has happened I go to the user's

70
00:07:43,360 --> 00:07:49,519
home directory once again notice we now have this blad2.txt and no surprise is what the content is

71
00:07:49,599 --> 00:07:54,639
actually going to be it's going to be the same content there we are right there so that's using

72
00:07:54,639 --> 00:08:02,719
scp the other one we can use is sftp which is file transfer protocol this time again using that ssh

73
00:08:02,719 --> 00:08:10,319
encryption the difference here is that with scp we actually make the transfer from the point of view

74
00:08:10,319 --> 00:08:17,839
that we are pushing the file from where it happens to reside to another server when we're using sftp

75
00:08:17,839 --> 00:08:23,519
we do it the reverse way but ultimately pulling the file from the server into the client who's

76
00:08:23,519 --> 00:08:30,159
receiving the file so to do the same type of transaction let's go and I'll clear the screen

77
00:08:30,719 --> 00:08:37,759
to an ls we have my personal stuff and on this directory here I'll just remove these text files

78
00:08:37,759 --> 00:08:45,439
by saying rm wildcard.txt ls so now we no longer have that file so as opposed to get on to the

79
00:08:45,440 --> 00:08:51,520
command line of server one and pushing that file to server two we're going to go on to the command

80
00:08:51,520 --> 00:08:57,680
line of server two and pull the file into server two using sftp so what I will do is I will use

81
00:08:57,680 --> 00:09:06,320
the command sftp and I will give the username of server one and the ip address of server one which is

82
00:09:06,320 --> 00:09:13,760
4.26 if I hit enter I'm going to have to log in if I just type in the password for server one right

83
00:09:14,319 --> 00:09:21,200
hit enter we now have this sftp connection I can do an ls we can see a listing of what is present

84
00:09:21,200 --> 00:09:28,159
here I can go into the documents directory do an ls here is the file which I want to pull from server

85
00:09:28,159 --> 00:09:35,600
one onto my local machine on server two what I can then do is just say get my personal stuff.txt

86
00:09:36,319 --> 00:09:42,639
and if I hit enter we've now fetched that particular file and what I can do here is I can just say

87
00:09:42,639 --> 00:09:49,919
quit and do an ls notice now that my personal stuff again is back on our directory so I can say

88
00:09:49,919 --> 00:09:54,960
cat my personal stuff and the contents is indeed right here the difference again here is that this

89
00:09:54,960 --> 00:10:01,120
time we had to log in from server two as the client and pull in that file using the credentials

90
00:10:01,120 --> 00:10:07,679
and the ip address of server one whereas with sftp we're doing the inverse the ultimate

91
00:10:07,679 --> 00:10:13,039
overriding principle though is that both connections were wrapped within that ssh connection fully

92
00:10:13,039 --> 00:10:18,719
encrypted and protected from eavesdroppers now similarly with sftp we can do the same

93
00:10:18,719 --> 00:10:24,879
type of thing if I just finally remove again this file one last time my personal stuff I can say

94
00:10:24,879 --> 00:10:32,319
sftp as we did before log into server one type in the password ls let's go back into the documents

95
00:10:32,320 --> 00:10:37,840
directory of server one ls again here is my personal stuff I can get it by saying my personal

96
00:10:37,840 --> 00:10:42,960
stuff and if I want to change the name what I could just do is just specify the name I want to

97
00:10:42,960 --> 00:10:49,600
pull it in as let's just say blah stuff blah and clearly run out of any type of creativities if I

98
00:10:49,600 --> 00:10:56,080
hit enter now we're going to copy this document I will say quits we do an ls but now the file has

99
00:10:56,080 --> 00:11:02,639
been renamed blah stuff blah and no surprises once again the contents are still the same so that

100
00:11:02,639 --> 00:11:09,680
really is us for using sftp and the scp function as ssh clients the next thing we'll be looking at

101
00:11:09,680 --> 00:11:16,639
is how we can use our ssh keys to log into our devices without having to specify our passwords

102
00:11:16,639 --> 00:11:20,080
and that's what we'll be looking at in the very next nugget so I hope this has been informative

103
00:11:20,080 --> 00:11:24,080
for you and I'd like to thank you for viewing

