Ubuntu Desktop 16 配置ssh远程登录

环境介绍

主机系统主机IP
虚拟机Ubuntu Desktop 16.04192.168.72.129
宿主机Windows192.168.72.1

步骤1-4在Ubuntu里操作,步骤5-6在Windows里操作

1.安装openssh-server

python@ubuntu:~$ sudo apt install openssh-server

2.允许用户登录;编辑配置文件

python@ubuntu:~$ sudo vim /etc/ssh/sshd_config

PermitRootLogin prohibit-password 改为:PermitRootLogin yes

在这里插入图片描述

3.重启sshd服务并检查状态

python@ubuntu:~$ systemctl restart sshd
python@ubuntu:~$ systemctl status sshd

在这里插入图片描述

4.查看Ubuntu主机的IP

python@ubuntu:~$ ip addr

在这里插入图片描述

5.远程登录Ubuntu

在Windows端打开CMDGit Bash 命令窗口,输入“ssh 用户名@目标主机IP

dev@HUAWEIPC-ZSY MINGW64 ~
$ ssh python@192.168.72.129
The authenticity of host '192.168.72.129 (192.168.72.129)' can't be established.
无法确定主机“192.168.72.129(192.168.82.129)”的真实性。
ED25519 key fingerprint is SHA256:NP8f+1IpUSsGTv52aYVrPf141xNbh0pKc8KajHTVEo8.
ED25519密钥指纹是SHA256:NP8f+1IpUSsGTv52aYVrPf141xNbh0pKc8KajHTVEo8。
This key is not known by any other names
此密钥不为任何其他名称所知
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
是否确实要继续连接?
Warning: Permanently added '192.168.72.129' (ED25519) to the list of known hosts.
警告:已将“192.168.72.129”(ED25519)永久添加到已知主机列表中。
python@192.168.72.129's password:
Permission denied, please try again.
权限被拒绝,请重试。
python@192.168.72.129's password:
Welcome to Ubuntu 16.04.7 LTS (GNU/Linux 4.15.0-142-generic x86_64)

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

0 updates can be applied immediately.
可以立即应用0个更新。

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系统包含的程序是自由软件;
每个程序的确切分发条款在/usr/share/doc/*/corpyright中的各个文件中进行了描述。

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
在适用法律允许的范围内,Ubuntu绝对没有担保。
python@ubuntu:~$

6.退出远程登录

python@ubuntu:~$ exit
logout
Connection to 192.168.72.129 closed.

参考文献

[1] Service - OpenSSH | Ubuntu https://ubuntu.com/server/docs/service-openssh

英语好的同学请忽略

英语好的同学,请忽略下文。附上 /etc/ssh/sshd_config 原文及一部分的机器翻译。

# Package generated configuration file
# 包生成的配置文件
# See the sshd_config(5) manpage for details
# 有关详细信息,请参阅sshd_config(5)手册页,官网地址 https://linux.die.net/man/5/sshd_config

# What ports, IPs and protocols we listen for
# 我们监听哪些端口、IP和协议?
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
# 使用这些选项来限制sshd将绑定到哪些接口/协议
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
# 协议版本2的主机密钥
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
# 为了安全起见,启用了特权分离。
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
# 临时版本1服务器密钥的生存期和大小。
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
# Syslog工具 授权
LogLevel INFO
# 日志级别 信息

# Authentication:
# 身份验证
LoginGraceTime 120
# 登录宽限时间
PermitRootLogin prohibit-password
#允许root登录 禁止密码
StrictModes yes
# 严格模式 yes

RSAAuthentication yes
# RSA身份验证 yes
PubkeyAuthentication yes
# 公钥身份验证 yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys
# 授权密钥文件

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
# 为了让它发挥作用,你还需要/etc/ssh_known_hosts中的主机密钥
RhostsRSAAuthentication no
# similar for protocol version 2
# 类似于协议版本2
HostbasedAuthentication no
# 基于主机的身份验证 no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
# 如果你不信任~/.ssh/known_hosts进行RhostsRSAAuthentication,请取消注释。
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
# 要启用空密码,请更改为“是”(不推荐)
PermitEmptyPasswords no
# 允许空密码 no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
# 更改为“yes”以启用质询响应密码(请注意某些PAM模块和线程的问题)
ChallengeResponseAuthentication no
# 质询响应身份验证 no

# Change to no to disable tunnelled clear text passwords
# 更改为“no”以禁用隧道明文密码
#PasswordAuthentication yes

# Kerberos是一种计算机网络授权协议,用来在非安全网络中,对个人通信以安全的手段进行身份认证
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# 通用安全服务应用程序接口(GSSAPI) 是为了让程序能够访问安全服务的一个应用程序接口
# The Generic Security Services Application Program Interface (GSSAPI, also GSS-API)
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# 清理凭据 yes

# 参考 http://www.hackdig.com/02/hack-592921.htm#%E4%BB%80%E4%B9%88%E6%98%AFX11-forwarding%EF%BC%9F
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
# 允许客户端传递区域设置环境变量。
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# 将其设置为“yes”以启用PAM身份验证、帐户处理和会话处理。
# 如果启用此选项,将允许通过ChallengeResponseAuthentication和PasswordAuthentication进行PAM身份验证。
# 根据你的PAM配置,通过ChallengeResponseAuthentication进行的PAM身份验证可能会绕过“PermitRootLogin without-password”设置。
# 如果只想在不使用PAM身份验证的情况下运行PAM帐户和会话检查,
# 请启用此选项,但将PasswordAuthentication和ChallengeResponseAuthentication设置为“no”。
UsePAM yes
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 你可以使用SSH协议在Ubuntu上远程连接。以下是步骤: 1. 确保Ubuntu已经安装了ssh服务。如果没有安装,可以通过以下命令进行安装: ``` sudo apt-get update sudo apt-get install openssh-server ``` 2. 在远程计算机上打开终端或命令提示符,输入以下命令: ``` ssh your_username@ubuntu_ip_address ``` 在这个命令中,your_username是你在Ubuntu上的用户名,ubuntu_ip_address是Ubuntu计算机的IP地址。 3. 如果是第一次连接,你需要确认连接并输入密码。以后,你可以使用ssh命令直接连接到Ubuntu计算机。 希望这可以帮助你远程连接到Ubuntu! ### 回答2: Ubuntu 是一个广泛应用于个人电脑、服务器和移动设备的开源操作系统。要远程连接 Ubuntu,可以使用一些常见的远程桌面协议和工具。 最常用的远程连接协议是远程桌面协议 (Remote Desktop Protocol, RDP)。通常情况下,可以通过安装远程桌面服务器 (Remote Desktop Server) 实现远程连接。在 Ubuntu 系统中,有两个常用的远程桌面服务器选择:VNC (Virtual Network Computing) 和 XRDP (X Remote Desktop Protocol)。 VNC 是一种允许用户通过网络在远程计算机上使用图形用户界面的协议。要启用 VNC 远程连接,可以首先安装 VNC 服务器,并设置用户权限和访问密码。然后,可以使用 VNC 客户端工具连接到 Ubuntu 计算机。 XRDP 是一个开源的实现了 Windows 远程桌面协议 (RDP) 的远程桌面服务器。要启用 XRDP 远程连接,可以通过安装 XRDP 软件包实现。然后,可以使用 Windows 上的远程桌面客户端工具连接到 Ubuntu 计算机。 除了以上两种方法,还可以通过 SSH (Secure Shell) 实现远程连接。SSH 是一种加密的网络协议,允许在不安全的网络上进行安全的远程登录和执行命令。要使用 SSH 远程连接 Ubuntu,首先需要在 Ubuntu 上安装和配置 SSH 服务器。然后,可以使用 SSH 客户端工具连接到远程 Ubuntu 计算机,并通过命令行界面进行管理和操作。 总而言之,要在Ubuntu系统上实现远程连接,可以选择安装并配置 VNC、XRDP 或 SSH 服务器,然后使用对应的客户端工具连接到远程计算机。这些方法都能够有效地实现远程管理和操作 Ubuntu 系统。 ### 回答3: Ubuntu是一种开源的操作系统,具有强大的远程连接功能。要在Ubuntu上进行远程连接,你可以使用远程桌面协议(RDP)或安全壳层(SSH)。 通过RDP连接到Ubuntu,首先需要在Ubuntu机器上安装和配置远程桌面服务。你可以在终端中输入以下命令来安装xrdp服务: sudo apt-get install xrdp 安装完成后,你可以使用Windows、Mac或其他支持RDP协议的远程桌面客户端来连接到Ubuntu。输入Ubuntu的IP地址,然后输入你的登录凭证,即可成功连接。 另一种远程连接Ubuntu的方式是使用SSHSSH提供了安全的远程访问并允许通过命令行界面远程管理UbuntuSSH默认是在Ubuntu上启用的,所以你无需再进行其他配置。 要在另一台计算机上连接UbuntuSSH服务器,你可以使用终端或其他SSH客户端。在终端中输入以下命令: ssh username@ubuntu_IP_address 其中,"username"是你在Ubuntu上的用户名,"ubuntu_IP_address"是Ubuntu机器上的IP地址。输入密码后,你将会成功连接到Ubuntu的终端界面。 无论你选择使用RDP还是SSH,远程连接到Ubuntu都是一种方便和安全的方式,可以实现远程管理和访问Ubuntu系统。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值