Changing Default Ports (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey Cybrarians, and welcome back
00:00
>> to the Linux plus course here at Cybrary.
00:00
>> I'm your instructor Rob Goelz.
00:00
In today's lesson,
00:00
we're going to cover changing default ports.
00:00
Upon completion of today's lesson,
00:00
you're going to be able to understand
00:00
the importance and benefits of changing ports
00:00
>> that are used by services that commonly define ports.
00:00
>> We're also going to use our demo today to modify SSH
00:00
>> in order to set it up to use a different default port.
00:00
>> Throughout the course, you've probably seen this icon.
00:00
The hand with the string tied around his finger,
00:00
tie a string around your fingers, don't forget.
00:00
This is put there so we'll remember ports
00:00
commonly used well-known ports
00:00
that we're going to know for the exam.
00:00
The flag with that icon,
00:00
and well-known ports are those that are assigned
00:00
the port number 0 through 1,023.
00:00
These are assigned by the Internet Assigned
00:00
Numbers Authority or IANA,
00:00
and registered ports are 1,024 through 49,151.
00:00
These are registered with IANA but not assigned,
00:00
essentially, these groups are
00:00
essentially ports that people know about and use.
00:00
If you choose to use them yourself,
00:00
you can sometimes bump into other things.
00:00
Another downside of using these ports
00:00
is that attackers also know these ports.
00:00
One method of providing security to an application
00:00
is to choose a different port than a standard one,
00:00
and one way that you can do this it just
00:00
by modifying the port that's in use,
00:00
changing it from something other than its default port.
00:00
Because remember in Linux everything is a file,
00:00
and a lot of times we can go into
00:00
>> the configuration file and change things like that.
00:00
>> But that being said,
00:00
if we're going to make modifications,
00:00
we need to notify others
00:00
>> and configure clients to use the new port,
00:00
>> unless we wind up with a bunch of confused holders.
00:00
Let's go ahead and see how we can modify
00:00
the SSH port with some demo time.
00:00
Here we are back in our demo environment
00:00
>> and if you remember, we have set this up
00:00
>> to do password less authentication.
00:00
>> We can just SSH to Ubuntu
00:00
and we can land on the Ubuntu environment.
00:00
But let's go ahead and change the default password
00:00
for SSH by modifying the open SSH server configuration.
00:00
Now we can do this by doing sudoedit etc/ssh/
00:00
and remember the server is sshd_config.
00:00
That's the config file for OpenSSH server.
00:00
We're gonna go in here once I provide the password.
00:00
What we can see right here is on about Line 15,
00:00
we have the port set to 22.
00:00
Now, we can just hit I for insert
00:00
>> and go in and delete this out and then modify it.
00:00
>> Remember, we could use one of these private ports.
00:00
We're going to pick the first private port we can use,
00:00
which is 49152,
00:00
and then what we'll do is we'll escape :wq to save
00:00
and quit out of this file and make that change.
00:00
Now, in order for this change,
00:00
we picked up what we need to do is
00:00
we need to do a system CTL,
00:00
restart SSH key,
00:00
and I'm going to put in my user password here
00:00
>> because I didn't do is sudo,
00:00
>> and the authentication is complete.
00:00
Now let's get back to our CentOS system from a buddy
00:00
I'm just can hit "Control D",
00:00
and now we're back on our CentOS system.
00:00
I'm going to hit "Control L" to clear the screen,
00:00
and what I'm going to try
00:00
>> and do now is do the SSH to Ubuntu again,
00:00
>> and now we've got an issue because
00:00
>> it says we can't connect
00:00
>> to that Ubuntu system on Port 22,
00:00
>> because it can actually refuse.
00:00
What we did was we changed the default port,
00:00
that the a bunch of server
00:00
>> will allow SSH to connect on.
00:00
>> So in order to do this now we have to specify
00:00
>> other port that we're gonna use.
00:00
>> Luckily, we can do that really easily here in SSH,
00:00
we can just use the -p flag for port,
00:00
and then say we want to connect down 49152
00:00
>> and hit "Enter"
00:00
>> and we're back in business.
00:00
>> We connect it through the n new port,
00:00
>> we're good to go.
00:00
>> With that, in this lesson,
00:00
>> we covered the importance
00:00
>> and benefits of modifying default ports.
00:00
Moving them away from things that people use
00:00
>> and hackers and attackers are aware of
00:00
>> so we can better protect your applications.
00:00
>> During the demo, we talked about
00:00
>> how to modify SSH to use a different default port.
00:00
>> Thanks so much for being here
00:00
>> and I look forward to seeing you in the next lesson.
Up Next