当前位置:   article > 正文

Ubuntu 20.04 - 安装、启用 OpenSSH 服务端_ubuntu openssh

ubuntu openssh

Ubuntu 系统信息:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.3 LTS
Release:	20.04
Codename:	focal
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

安装 OpenSSH 服务端

在 Ubuntu 操作系统中,使用 sudo apt-get install openssh-server 安装 OpenSSH 服务端:

$ sudo apt-get install openssh-server
  • 1

安装完成,使用 sudo systemctl status sshd 命令查看 OpenSSH 服务端的状态(第 1 行),可知 OpenSSH 服务端已经在运行(第 4 行):

$ sudo systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-02-21 09:09:50 CST; 50s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 4051 (sshd)
      Tasks: 1 (limit: 4588)
     Memory: 1.0M
     CGroup: /system.slice/ssh.service
             └─4051 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

221 09:09:50 mk-virtual-machine systemd[1]: Starting OpenBSD Secure Shell server...
221 09:09:50 mk-virtual-machine sshd[4051]: Server listening on 0.0.0.0 port 22.
221 09:09:50 mk-virtual-machine sshd[4051]: Server listening on :: port 22.
221 09:09:50 mk-virtual-machine systemd[1]: Started OpenBSD Secure Shell server.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

使用 SSH 客户端连接 SSH 服务端

在 Windows 10 操作系统中,打开 PowerShell,使用 ssh -l login_name destination 命令格式连接目标主机:

PS C:\Users\Admin> ssh -l mk 192.168.132.134
The authenticity of host '192.168.132.134 (192.168.132.134)' can't be established.
ECDSA key fingerprint is SHA256:U3XR4lbb5hhSp4fCycZwN/gO5thnzQ7K9EqcQ1HU5zM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.132.134' (ECDSA) to the list of known hosts.
mk@192.168.132.134's password:
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.13.0-30-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

89 updates can be applied immediately.
1 of these updates is a standard security update.
To see these additional updates run: apt list --upgradable

Your Hardware Enablement Stack (HWE) is supported until April 2025.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

登录成功,查看谁正在登录:

mk@mk-virtual-machine:~$ w
 11:28:20 up  2:32,  2 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
mk       :0       :0               08:56   ?xdm?  44.74s  0.01s /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHEL
mk       pts/1    192.168.132.1    10:51    0.00s  0.03s  0.01s w
  • 1
  • 2
  • 3
  • 4
  • 5

参考

如何在Ubuntu 20.04上启用SSH

SSH/OpenSSH/Configuring

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/185183
推荐阅读
相关标签
  

闽ICP备14008679号