关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

debian操作系统如何开启SSH服务

发布时间:2023-02-12 12:29:43
1491984010112764.jpg

最近要调试新的程序,买了一台服务器安装了pve,虚拟化了几台Debian系统。发现远程连接不了,检测发现ssh服务进程不存在,这就好办了,安装ssh服务再修改配置进行端口转发访问。

更新系统和安装ssh服务

# 更新系统软件源apt-get update# 安装ssh服务apt-get install -y ssh# 安装vim编辑器apt-get install -y vim

ssh安装完成后,检查运行状态,一般安装完成后都会自动启动。

# 开启ssh服务/etc/init.d/ssh start# 关闭ssh服务/etc/init.d/ssh stop# 重启ssh服务/etc/init.d/ssh restart# 查看ssh运行状态/etc/init.d/ssh status
image.png

备份bak文件并进行修改配置文件

备份ssh配置文件

cp /etc/ssh/sshd_config{,.bak}

利用vim编辑器进行对/etc/ssh/sshd_congif配置进行修改

image.png
Include /etc/ssh/sshd_config.d/*.conf# 访问远程端口Port 22# 允许root登录PermitRootLogin yes# 使用密码认证PasswordAuthentication yes# 是否允许空密码登录PermitEmptyPasswords no# 密码认证ChallengeResponseAuthentication no# 身份认证模块UsePAM yes# x11连接重定向X11Forwarding yes# 显示上次登录的信息PrintMotd no# 允许客户端使用变量名AcceptEnv LANG LC_*# 使用sftpSubsystem       sftp    /usr/lib/openssh/sftp-server

查看配置文件,一般都默认开启部分参数。只需要参照上面的参数进行修改就可以了,把#注释去掉就可以开启该功能。yes表示开启该功能,no表示不开启功能,#注释表示禁用该配置。

修改完成保存后,进行重启ssh服务

/etc/init.d/ssh restart



/template/Home/8a/PC/Static