How to install SSH in Ubuntu

2020-06-05 15:41:00
Ley Boi
Original
1741
Résumé:SSH is a network protocol used for encrypted login between computers.If a user could log in to a remote computer using the SSH protocol from a local computer, this login is safe, and even if it is intercepted halfway, the password will not be disclosed.

Intro

SSH is a network protocol used for encrypted login between computers.
If a user could log in to a remote computer using the SSH protocol from a local computer, this login is safe, and even if it is intercepted halfway, the password will not be disclosed.

1. Install SSH

Open your terminal and run 

sudo apt-get install openssh-server

2. Edit the configuration file

Run

sudo vim /etc/ssh/sshd_config
and change  PermitRootLogin  to yes, so root user can log in.
...
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
...

3. Install the UFW

Run

sudo apt-get install ufw

4. Allow a port

Run

sudo ufw allow 22
to allow port number 22.

5. Close the UFW

If temporarily close the UFW, run

sudo ufw enable
If permanently  close the UFW, run

sudo ufw disable

6. Connect

Run ifconfig to check the IP (e.g. 192.168.192.128). Connect to this IP through the SSH connection tool, and enter the account and password to connect.


root@ubuntu:~# ifconfig
docker0: flags=4163 mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:37ff:fe4e:34da prefixlen 64 scopeid 0x20
ether 02:42:37:4e:34:da txqueuelen 0 (Ethernet)
RX packets 14 bytes 2348 (2.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 65 bytes 6916 (6.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33: flags=4163 mtu 1500
inet 192.168.192.128 netmask 255.255.255.0 broadcast 192.168.192.255
inet6 fe80::6963:2d68:8113:d16 prefixlen 64 scopeid 0x20
ether 00:0c:29:1e:44:b8 txqueuelen 1000 (Ethernet)
RX packets 101298 bytes 144452064 (144.4 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 24067 bytes 1818654 (1.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

You can also read more tech blogs below,
Commenter
Commentaires reçus après vérification。