[LINUX] Ubuntu (18.04.3) SSH edition

1. Update
$sudo apt update

This is basically done every time.

2. Change root password
$ sudo passwd root

Set a password for root privileges.

It's a little scary, so set it longer.

I was able to log in to Root for the time being.

$ sudo su -

This will switch to the root prompt.

Add the following here with vi.

/etc/ssh/sshd_config

+ PermitRootLogin no

You can disable root login by restarting sshd.

$ systemctl restart ssh
$ failed to restart sshd.service unit sshd.service not found

Fa! ??

As I investigated, I had to install openssh-server in the first place.

$ sudo apt-get install openssh-server

Then, fix the following

/etc/ssh/sshd_config

- PermitRootLogin prohibit-password
+ PermitRootLogin no

Reboot.

$ sudo /etc/init.d/ssh restart

Yes ... (Can't you restart?).

When I looked it up, I had to start the sshd service.

$ sudo aptitude install ssh

Try entering from the Mac terminal.

$ ssh [email protected] address

Oh, it's done.

Try to log in to root.

$ su root

If you can't log in with this, it's OK.

3. sshd port settings The following changes.

/etc/ssh/sshd_config

- # Port 22
+ Port 2022

Reboot.

$ sudo /etc/init.d/ssh restart

That's it.

4. Firewall port number closed → new port setting Check below.
$ sudo ufw status

22 that was released last time is deleted (it seems not so good)

$ sudo ufw delete allow 22

New port open

$ sudo ufw allow 2022
$ sudo ufw reload

2022 is now open

Confirm that you cannot enter with ↓.

$ssh account [email protected] address

I couldn't enter without ↓.

$ ssh -p port number account [email protected] address

Finally It started at 9 pm and it was such a time.

I will go to bed tomorrow.

Next time, I would like to connect using the public key authentication method.

(It doesn't stop when you start it)

Recommended Posts

Ubuntu (18.04.3) SSH edition
Ubuntu Linux 20.04
SSH memo
ubuntu codename
Ubuntu best