1
00:00:00,565 --> 00:00:02,212
- [Instructor] Hi and
welcome back to the course.

2
00:00:02,212 --> 00:00:03,995
In this video I'm going
to quickly talk about

3
00:00:03,995 --> 00:00:05,578
what an SSH key is.

4
00:00:07,123 --> 00:00:10,956
An SSH key is a way of
encrypting information.

5
00:00:12,020 --> 00:00:14,330
Whenever you generate an SSH key there

6
00:00:14,330 --> 00:00:18,497
are two keys generated, a
public key and a private key.

7
00:00:21,436 --> 00:00:25,604
Anybody that has a public
key can decrypt information.

8
00:00:25,604 --> 00:00:29,187
If you have the public
key you can decrypt.

9
00:00:30,833 --> 00:00:34,416
Those who have the
private key can encrypt.

10
00:00:36,270 --> 00:00:37,937
What does this mean?

11
00:00:38,946 --> 00:00:42,797
You have a private key so you can use that

12
00:00:42,797 --> 00:00:44,547
to encrypt some data.

13
00:00:45,506 --> 00:00:47,356
Don't tell me about how it's encrypted but

14
00:00:47,356 --> 00:00:51,012
just know that it uses the key to encrypt.

15
00:00:51,012 --> 00:00:53,831
Then, you also have the public key so

16
00:00:53,831 --> 00:00:55,998
you can decrypt that data.

17
00:00:57,480 --> 00:01:00,758
Anybody who doesn't have the
public key cannot decrypt.

18
00:01:00,758 --> 00:01:03,890
So what you do is you
share your public key

19
00:01:03,890 --> 00:01:08,057
with those services that you
want to communicate with.

20
00:01:09,248 --> 00:01:11,491
That way if they have your public key

21
00:01:11,491 --> 00:01:14,908
they can decrypt data that you send them.

22
00:01:16,841 --> 00:01:18,757
Why is this useful?

23
00:01:18,757 --> 00:01:22,022
For example say you share your public key

24
00:01:22,022 --> 00:01:25,772
with Github, then whenever
you send them data

25
00:01:26,663 --> 00:01:29,996
that is encrypted using your private key

26
00:01:32,008 --> 00:01:33,786
they know that it's
coming from you if they

27
00:01:33,786 --> 00:01:37,164
can decrypt it because no other public key

28
00:01:37,164 --> 00:01:39,581
can decrypt your private key.

29
00:01:41,558 --> 00:01:42,903
That means that you don't
have to put your username

30
00:01:42,903 --> 00:01:45,070
and password in basically.

31
00:01:46,133 --> 00:01:49,172
In order to do that you
first need to generate

32
00:01:49,172 --> 00:01:50,755
an SSH key locally.

33
00:01:52,356 --> 00:01:55,964
It's very easy to do with
a terminal such as the get

34
00:01:55,964 --> 00:01:59,578
four bash, the bash
forget in windows or the

35
00:01:59,578 --> 00:02:01,403
terminal in mac or linux.

36
00:02:01,403 --> 00:02:03,736
You can do SSH dash key gen.

37
00:02:06,988 --> 00:02:09,455
And then that will start
generating the public

38
00:02:09,455 --> 00:02:11,288
and private key pairs.

39
00:02:12,742 --> 00:02:16,909
You can enter a file in which
you wish to save the key.

40
00:02:17,936 --> 00:02:20,017
Here I would just leave it as the default

41
00:02:20,017 --> 00:02:23,078
unless you already have other keys.

42
00:02:23,078 --> 00:02:26,510
You can have many keys and
your computer is the only

43
00:02:26,510 --> 00:02:29,290
person, not a person
really, is the only thing

44
00:02:29,290 --> 00:02:31,540
that knows the private key.

45
00:02:32,743 --> 00:02:36,004
You should generate a key
for every device you've got

46
00:02:36,004 --> 00:02:38,268
but the device itself should generate it.

47
00:02:38,268 --> 00:02:40,462
You can only generate
a key for your computer

48
00:02:40,462 --> 00:02:41,962
from the terminal.

49
00:02:43,802 --> 00:02:47,855
You can generate a key
and once that's done

50
00:02:47,855 --> 00:02:50,406
I'm gonna cancel it, but
you can continue with it.

51
00:02:50,406 --> 00:02:54,150
It may ask you for a
pass phrase, essentially

52
00:02:54,150 --> 00:02:55,473
a password that you'll have to put in

53
00:02:55,473 --> 00:02:57,066
whenever you use the key.

54
00:02:57,066 --> 00:03:00,733
You can put one in if you want
or you can leave it blank.

55
00:03:00,733 --> 00:03:05,470
After that, you can share
your public key with Github.

56
00:03:05,470 --> 00:03:09,637
The way to do that is to go
to the address, the path here

57
00:03:10,928 --> 00:03:15,095
of the public key and do
cat slash users slash jslvtr

58
00:03:18,113 --> 00:03:21,030
slash dot ssh slash id rsa dot pub.

59
00:03:22,725 --> 00:03:26,892
This is your public key, so
cat that, this one is hidden

60
00:03:28,362 --> 00:03:32,234
obvious, for obvious
reasons, but you want to

61
00:03:32,234 --> 00:03:33,484
copy all of it.

62
00:03:34,450 --> 00:03:38,617
It starts with SSH dash
rsa and it should end with

63
00:03:39,524 --> 00:03:41,774
your name at your computer.

64
00:03:43,065 --> 00:03:45,847
So copy all of it and
make sure it's copied

65
00:03:45,847 --> 00:03:49,382
and go over to Github
and you can go on your

66
00:03:49,382 --> 00:03:53,049
profile, edit your
profile, SSH and gpg keys

67
00:03:57,471 --> 00:04:00,638
and at the very top add a new SSH key.

68
00:04:01,784 --> 00:04:04,841
Here you can give it a title if you want.

69
00:04:04,841 --> 00:04:08,489
My key at my laptop,
you can give it whatever

70
00:04:08,489 --> 00:04:12,406
title you want and then
paste in the key there.

71
00:04:16,387 --> 00:04:18,259
Want to make sure that there are no spaces

72
00:04:18,259 --> 00:04:20,346
between any of the letters.

73
00:04:20,346 --> 00:04:22,773
For example, this is an I there, and then

74
00:04:22,773 --> 00:04:24,734
there's a j, you want
to make sure there's no

75
00:04:24,734 --> 00:04:26,859
space or new line between anything.

76
00:04:26,859 --> 00:04:28,800
You also don't want to
delete any characters.

77
00:04:28,800 --> 00:04:31,082
Every character is essential
and you want to make

78
00:04:31,082 --> 00:04:33,241
sure there's a new line
and a space between

79
00:04:33,241 --> 00:04:37,926
the SSH dash rsa and the
next thing and once you're

80
00:04:37,926 --> 00:04:39,882
convinced that everything is fine

81
00:04:39,882 --> 00:04:42,215
you just go and add SSH key.

82
00:04:45,350 --> 00:04:46,813
This case, it says my
key is already in use

83
00:04:46,813 --> 00:04:49,190
because I've already
added my key to Github

84
00:04:49,190 --> 00:04:52,184
but in your case it should add it fine.

85
00:04:52,184 --> 00:04:56,129
When that's done, then
you should be able to,

86
00:04:56,129 --> 00:04:59,212
when you create or edit a repository,

87
00:05:01,544 --> 00:05:04,961
for example, I've got my repository here,

88
00:05:06,785 --> 00:05:10,741
you should be able to modify
the origin if you want,

89
00:05:10,741 --> 00:05:12,719
it's not really necessary to be

90
00:05:12,719 --> 00:05:14,969
the SSH version of the url.

91
00:05:18,384 --> 00:05:20,635
When you do that you
will no longer be asked

92
00:05:20,635 --> 00:05:24,118
for your password as long
as you are in the laptop

93
00:05:24,118 --> 00:05:27,775
that you generated the SSH key with.

94
00:05:27,775 --> 00:05:32,290
Really it's just a matter
of slightly higher security.

95
00:05:32,290 --> 00:05:36,526
If you do want to do
that, make sure to use SSH

96
00:05:36,526 --> 00:05:40,861
copy all of that, like
that and then go back to

97
00:05:40,861 --> 00:05:44,527
the terminal, I'm going to
clear and then you can do

98
00:05:44,527 --> 00:05:48,694
get remote remove origin,
get remote add origin and

99
00:05:51,711 --> 00:05:52,878
paste that in.

100
00:05:54,735 --> 00:05:55,902
And that's it.

101
00:05:57,011 --> 00:05:59,387
So once you've done
that you now know a bit

102
00:05:59,387 --> 00:06:01,043
more about SSH and how it works.

103
00:06:01,043 --> 00:06:04,055
It works by sharing your
public key with others

104
00:06:04,055 --> 00:06:06,936
and keeping your private
key secret and never

105
00:06:06,936 --> 00:06:09,401
sharing it with anybody
else because if you do

106
00:06:09,401 --> 00:06:12,345
then they can encrypt
information using your

107
00:06:12,345 --> 00:06:16,192
private key and when a
service like Github can

108
00:06:16,192 --> 00:06:19,929
decrypt it, they will think
the person sending them

109
00:06:19,929 --> 00:06:22,402
data is you, because only
you should have access

110
00:06:22,402 --> 00:06:24,069
to your private key.

111
00:06:25,293 --> 00:06:28,489
If you share your private
key you can basically,

112
00:06:28,489 --> 00:06:30,309
other people can pretend to be you.

113
00:06:30,309 --> 00:06:32,668
So that's not a good thing.

114
00:06:32,668 --> 00:06:35,174
That's everything that I wanted
to tell you about SSH keys.

115
00:06:35,174 --> 00:06:37,558
Hopefully that's cleared some doubts out

116
00:06:37,558 --> 00:06:40,800
and again that's just a
small tip of the iceberg

117
00:06:40,800 --> 00:06:43,427
on what security is about
and I would encourage you

118
00:06:43,427 --> 00:06:47,940
to explore and learn more about
that if you're interested.

119
00:06:47,940 --> 00:06:50,759
That's it for this video so
thanks very much for watching.

120
00:06:50,759 --> 00:06:53,042
I'll see you in the next one.

