ubantu安装配置ssh协议

安装OpenSSH

apt update

apt install openssh-server

systemctl start ssh

设置系统启动时运行

system enable ssh

ssh服务是否正在运行

systemctl status ssh

$ vim /etc/ssh/sshd_config

*PermitRootLogin

PermitRootLogin 参数用于控制是否允许root用户通过SSH远程登录。其配置选项通常包括:

yes:允许root用户远程登录。

no:不允许root用户远程登录。

prohibit-password:不允许root用户使用密码远程登录,但可以使用其他身份验证方式(如公钥认证)。

forced-commands-only:仅允许root用户执行特定的命令,这通常用于特定的管理任务。

*PasswordAuthentication

PasswordAuthentication 参数用于控制是否允许使用密码身份验证。其配置选项通常包括:

yes:允许使用密码身份验证。

no:不允许使用密码身份验证,必须使用其他身份验证方式(如公钥认证)。

允许root用户远程登录

PermitRootLogin yes

允许使用密码身份验证

PasswordAuthentication yes

不允许root用户使用密码远程登录

PermitRootLogin prohibit-password

允许其他用户使用密码身份验证

PasswordAuthentication yes

修改SSH配置文件后,你需要重启SSH服务以使更改生效。可以通过运行sudo systemctl restart sshd

***由于WSL的Ubuntu通常不会直接暴露一个可通过网络访问的IP地址,因此您可能需要使用Windows的OpenSSH客户端来设置一个SSH隧道(端口转发),以便Putty能够连接到WSL的Ubuntu。这通常涉及到在Windows的命令提示符中使用ssh命令来设置一个隧道,例如:ssh -L 2222:localhost:22 your-wsl-username@localhost(这里2222是Windows上的本地端口,22是WSL Ubuntu上的SSH端口)。然后,在Putty中,您应该连接到localhost:2222

相关推荐
敲代码还房贷2 小时前
解决win7装不了vmware tools问题
ubuntu
下午写HelloWorld5 小时前
Linux系统及Ubuntu常用指令
linux·ubuntu·操作系统
哆啦A梦——10 小时前
Ubuntu 虚拟机 Docker 与 MySQL 8.0.42 部署指南
mysql·ubuntu·docker
上天_去_做颗惺星 EVE_BLUE11 小时前
【新 Linux 服务器上手全攻略】系统巡检、存储规划与开发环境初始化
linux·运维·服务器·ubuntu·macos·centos
das2m11 小时前
WSL2 Ubuntu 配置完美版 docker compose 指南
linux·ubuntu·docker
MIXLLRED11 小时前
Ubuntu 22.04 + ROS2 Humble 上部署 ScaRF‑SLAM指南
ubuntu·slam·ros2·离线建图
FlyWIHTSKY12 小时前
JavaScript 和 TypeScript 分别是什么,可以相互写吗
javascript·ubuntu·typescript
iRayCheung12 小时前
virtualbox安装的ubuntu系统跑numpy报错
linux·ubuntu·numpy
zahuilg1013 小时前
Mac原生终端SSH一键快捷连接|无需装软件、极简安装、快速上手
macos·ssh·github·终端
丑过三八线13 小时前
Systemd Cgroup 驱动详解
linux·ubuntu·容器