在Ubuntu中,启用SSH可以远程连接和管理服务器:如何

安装Ubuntu服务器或桌面后,您有一个问题:默认在Ubuntu上启用了SSH?那么答案是绝对的'。用户或管理员必须通过触发单行命令来安装或启用SSH,我们将在本文中显示。但是在此之前,让我们看看什么是SSH?

固定外壳(SSH)是一项协议,它允许我们通过安全频道远程连接Ubuntu服务器或桌面。它允许运行所有命令,远程运行我们可以在服务器上实际运行的命令。甚至用户也可以运行命令行和图形程序,传输文件,甚至可以通过Internet创建安全的虚拟专用网络。它是由IETF网络工作组和更可靠的协议开发的,该协议为远程登录会话和其他网络服务提供了安全性。 SSH最初是UNIX系统上的程序,后来迅速扩展到其他操作平台。 SSH客户端可在Linux,Solaris,Windows,MacOS等多个平台上找到。

在这里,我们让您知道如何在Ubuntu(18.04,17.04,16.04,14.04…)或Linux Mint上启用SSH。

  1. 打开指挥末端l在Ubuntu服务器或桌面上。
  2. 要在图形模式下打开命令终端,用户可以使用快捷方式Ctrl+Alt+t
  3. 作为标准用户或根登录。对于root,一个人可以使用sudo -i
  4. 运行命令:sudo apt-get安装ssh
  5. 以上命令将安装三个软件包:OpenSSH-CLIENT,OPENSSH-SERVER和OPENSSH-SFTP-SERVER。
  6. 一旦安装了SSH服务器,使用此命令在Ubuntu上启用它:sudo服务SSH开始
  7. 现在,使用以下方式检查Ubuntu上的SSH服务器的状态:sudo服务SSH状态

如果要编辑SSH的某些设置,例如侦听端口,root登录权限以及可以通过此命令编辑配置文件来完成的更多信息:

sudo nano /etc/ssh/sshd_config

上述所有命令的输出:

h2s@DESKTOP-N53EEI1:~$ sudo apt-get install ssh
[sudo] password for h2s:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libgsoap-2.8.60 libvncserver1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
openssh-client openssh-server openssh-sftp-server
Suggested packages:
keychain libpam-ssh monkeysphere ssh-askpass molly-guard rssh
The following NEW packages will be installed:
ssh
The following packages will be upgraded:
openssh-client openssh-server openssh-sftp-server
3 upgraded, 1 newly installed, 0 to remove and 174 not upgraded.
Need to get 997 kB of archives.
After this operation, 106 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-sftp-server amd64 1:7.6p1-4ubuntu0.3 [45.6 kB]
Get:2 https://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-server amd64 1:7.6p1-4ubuntu0.3 [333 kB]
Get:3 https://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssh-client amd64 1:7.6p1-4ubuntu0.3 [614 kB]
Get:4 https://archive.ubuntu.com/ubuntu bionic-updates/main amd64 ssh all 1:7.6p1-4ubuntu0.3 [5204 B]
Fetched 997 kB in 5s (197 kB/s)
Preconfiguring packages ...
(Reading database ... 99318 files and directories currently installed.)
Preparing to unpack .../openssh-sftp-server_1%3a7.6p1-4ubuntu0.3_amd64.deb ...
Unpacking openssh-sftp-server (1:7.6p1-4ubuntu0.3) over (1:7.6p1-4) ...
Preparing to unpack .../openssh-server_1%3a7.6p1-4ubuntu0.3_amd64.deb ...
Unpacking openssh-server (1:7.6p1-4ubuntu0.3) over (1:7.6p1-4) ...
Preparing to unpack .../openssh-client_1%3a7.6p1-4ubuntu0.3_amd64.deb ...
Unpacking openssh-client (1:7.6p1-4ubuntu0.3) over (1:7.6p1-4) ...
Selecting previously unselected package ssh.
Preparing to unpack .../ssh_1%3a7.6p1-4ubuntu0.3_all.deb ...
Unpacking ssh (1:7.6p1-4ubuntu0.3) ...
Processing triggers for ufw (0.35-5) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up openssh-client (1:7.6p1-4ubuntu0.3) ...
Setting up openssh-sftp-server (1:7.6p1-4ubuntu0.3) ...
Setting up openssh-server (1:7.6p1-4ubuntu0.3) ...
Creating SSH2 RSA key; this may take some time ...
2048 SHA256:5AdbGb5TQhr0muu4hOz49gdBC8iRRqonYXv0s0JUUHE root@DESKTOP-N53EEI1 (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:m1ibvVu6wqieTG8Yd98ocAHv3X6XqYCuhx56zq7Jgzc root@DESKTOP-N53EEI1 (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:SF2xPgLXsCG1Z6yEF7/+wrqTxxptiyuimxgnC7XVpwc root@DESKTOP-N53EEI1 (ED25519)
invoke-rc.d: could not determine current runlevel
Setting up ssh (1:7.6p1-4ubuntu0.3) ...
h2s@DESKTOP-N53EEI1:~$ sudo service ssh status
* sshd is not running
h2s@DESKTOP-N53EEI1:~$ sudo apt-get install openssh-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssh-server is already the newest version (1:7.6p1-4ubuntu0.3).
The following packages were automatically installed and are no longer required:
libgsoap-2.8.60 libvncserver1
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 174 not upgraded.
h2s@DESKTOP-N53EEI1:~$ sudo service ssh start
* Starting OpenBSD Secure Shell server sshd [ OK ]
h2s@DESKTOP-N53EEI1:~$ sudo service ssh status
* sshd is running
h2s@DESKTOP-N53EEI1:~$

其他有用的教程:

从B.Tech(荣誉)电子和仪器工程师到摄影和写博客;他最终对一切都有答案。哦,他在快速建立关系并建立信任方面也很出色。他的文章证明了这一点...