安装openssh服务 tony@ubuntu:~/Desktop$ sudo apt install openssh-server Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: ncurses-term openssh-sftp-server ssh-import-id Suggested packages: molly-guard monkeysphere ssh-askpass The following NEW packages will be installed: ncurses-term openssh-server openssh-sftp-server ssh-import-id 0 upgraded, 4 newly installed, 0 to remove and 51 not upgraded. Need to get 688 kB of archives. After this operation, 6,010 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 ncurses-term all 6.2-0ubuntu2 [249 kB] Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-sftp-server amd64 1:8.2p1-4ubuntu0.1 [51.5 kB] Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-server amd64 1:8.2p1-4ubuntu0.1 [377 kB] Get:4 http://us.archive.ubuntu.com/ubuntu focal/main amd64 ssh-import-id all 5.10-0ubuntu1 [10.0 kB] Fetched 688 kB in 6s (117 kB/s) Preconfiguring packages ... Selecting previously unselected package ncurses-term. (Reading database ... 143479 files and directories currently installed.) Preparing to unpack .../ncurses-term_6.2-0ubuntu2_all.deb ... Unpacking ncurses-term (6.2-0ubuntu2) ... Selecting previously unselected package openssh-sftp-server. Preparing to unpack .../openssh-sftp-server_1%3a8.2p1-4ubuntu0.1_amd64.deb ... Unpacking openssh-sftp-server (1:8.2p1-4ubuntu0.1) ... Selecting previously unselected package openssh-server. Preparing to unpack .../openssh-server_1%3a8.2p1-4ubuntu0.1_amd64.deb ... Unpacking openssh-server (1:8.2p1-4ubuntu0.1) ... Selecting previously unselected package ssh-import-id. Preparing to unpack .../ssh-import-id_5.10-0ubuntu1_all.deb ... Unpacking ssh-import-id (5.10-0ubuntu1) ... Setting up openssh-sftp-server (1:8.2p1-4ubuntu0.1) ... Setting up openssh-server (1:8.2p1-4ubuntu0.1) ...
Creating config file /etc/ssh/sshd_config with new version Creating SSH2 RSA key; this may take some time ... 3072 SHA256:kqACe+gbHMcR9JkngU+1DbODJZJEswuAwFJOpgIQKcc root@ubuntu (RSA) Creating SSH2 ECDSA key; this may take some time ... 256 SHA256:1XTWKEQcYj0lD/bVLknF/rCQhF1K+1AAxmagW758zlM root@ubuntu (ECDSA) Creating SSH2 ED25519 key; this may take some time ... 256 SHA256:cQdi29OAp1pbdlcwczgYqcA+M/6NOv+VwjnpVsYJcL8 root@ubuntu (ED25519) Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service. Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service. rescue-ssh.target is a disabled or a static unit, not starting it. Setting up ssh-import-id (5.10-0ubuntu1) ... Attempting to convert /etc/ssh/ssh_import_id Setting up ncurses-term (6.2-0ubuntu2) ... Processing triggers for systemd (245.4-4ubuntu3.2) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for ufw (0.36-6) ... 安装后查看ssh服务,已经自动运行起来了 tony@ubuntu:~/Desktop$ sudo systemctl status ssh ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2020-08-14 16:04:46 CST; 26s ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 10580 (sshd) Tasks: 1 (limit: 2285) Memory: 1.4M CGroup: /system.slice/ssh.service └─10580 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
Aug 14 16:04:46 ubuntu systemd[1]: Starting OpenBSD Secure Shell server... Aug 14 16:04:46 ubuntu sshd[10580]: Server listening on 0.0.0.0 port 22. Aug 14 16:04:46 ubuntu sshd[10580]: Server listening on :: port 22. Aug 14 16:04:46 ubuntu systemd[1]: Started OpenBSD Secure Shell server.