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

相关推荐
没有不重的名么6 小时前
Tmux Xftp及Xshell的服务器使用方法
服务器·人工智能·深度学习·机器学习·ssh
clever10118 小时前
在ubuntu系统上离线安装jenkins的做法
ubuntu·servlet·jenkins
Nie_Xun1 天前
ubuntu网络共享
linux·运维·ubuntu
wuicer2 天前
ubuntu 20.04 安装anaconda以及安装spyder
linux·运维·ubuntu
shuangrenlong2 天前
ubuntu更新chrome版本
linux·chrome·ubuntu
基于python的毕设2 天前
C语言栈的实现
linux·c语言·ubuntu
穷人小水滴2 天前
在 windows 运行 flatpak 应用 (WSL)
linux·windows·ubuntu
mit6.8242 天前
ubuntu远程桌面很卡怎么解决?
linux·ubuntu·php
morliz子轩3 天前
基于WSL搭建Ubuntu 22.04.x LTS开发环境
linux·运维·ubuntu
路多辛3 天前
Debian新一代的APT软件源配置文件格式DEB822详解
linux·运维·ubuntu·debian