Ubuntu19.10 open ssh service (detailed process)

It took me more than an hour to open ssh on Ubuntu, mainly because the tutorial steps I read at the beginning were not detailed, and then I turned on a host with more than 10,000, and the switch was very slow. Record the detailed steps here, which is convenient Check it out later

The first step is to check whether ssh has been turned on

sudo ps -e | grep ssh

If the last return is sshd, it proves that ssh has been turned on, skip to the fourth step

The second step, if there is no display, try to open the ssh service

sudo /etc/init.d/ssh start

If the command is not found, it proves that the ssh service is not installed

The third step is to install the openssh service to check if the service is turned on

sudo apt-get install openssh-server
sudo ps -e | grep ssh

If not, run the open command

sudo /etc/init.d/ssh start

The fourth step is to check whether the firewall has open port 20 (ssh opens port 22 by default, if you modify it, see step five)

netstat -an | grep 22
# or
ufw status

If not, open port 22

ufw allow 22

The fifth step, modify the ssh port (can be skipped)

sudo vi /etc/ssh/sshd_config

ssh restart

service sshd restart

The sixth step, the firewall takes effect and starts up

ufw enable

The seventh step, check the ip address, remember the ip address, and set a static ip

ifconfig

Set static ip:
Open vim /etc/netplan/ and check it. I have read other people's articles on vim /etc/netplan/01-netcfg.yaml, but mine is 50-cloud-init.yaml, so it should not be the same

cd /etc/netplan/
ls
vim 50-cloud-init.yaml 

Set as

network:
 ethernets:
 enp3s0:
  dhcp4:false
  addresses:[192.168.101.135/24]
  gateway4:192.168.101.1
  nameservers:
   addresses:[192.168.101.1,8.8.8.8]
 enp4s0:
  dhcp4:true
 version:2

Next, ping the computer to see if it can't work. If it doesn't work, see if it's on the same subnet and gateway, then download xshell or putty, and remember to make sure that the port is not wrong.

Optional: Set to log in ssh as root

sudo vim /etc/ssh/sshd_config

Change PermitRootLogin prohibit-password to PermitRootLogin yes
Remember to restart ssh

sudo systemctl restart sshd

Then the next step is to connect the computer with xshell or putty, remember to select 22 for the port number, if it is not changed

This is the end of this article about opening ssh service on Ubuntu 19.10 (detailed process). For more related Ubuntu 19.10 opening ssh content, please search for previous articles of ZaLou.Cn or continue to browse related articles below. Hope you all Support ZaLou.Cn a lot!

Recommended Posts

Ubuntu19.10 open ssh service (detailed process)
Open SSH service under Ubuntu
Open SSH service under Ubuntu
Open ssh on Ubuntu/Mac
Ubuntu ssh Android phone
ubuntu open designated port
Ubuntu opens SSH service for remote login and file transfer
Detailed ubuntu 20.04 LTS installation record
Graphical centos installation detailed process
ubuntu7.10 installed to 3D open
DNS service construction under Ubuntu
ubuntu: control & view process
Detailed explanation of the installation and use of SSH in the Ubuntu environment