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

更新系统和安装ssh服务

BASH
# 更新系统软件源
apt-get update
# 安装ssh服务
apt-get install -y ssh
# 安装vim编辑器
apt-get install -y vim
点击展开查看更多

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

BASH
# 开启ssh服务
/etc/init.d/ssh start

# 关闭ssh服务
/etc/init.d/ssh stop

# 重启ssh服务
/etc/init.d/ssh restart

# 查看ssh运行状态
/etc/init.d/ssh status
点击展开查看更多

ssh

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

备份ssh配置文件

BASH
cp /etc/ssh/sshd_config{,.bak}
点击展开查看更多

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

ssh

BASH
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_*
# 使用sftp
Subsystem       sftp    /usr/lib/openssh/sftp-server
点击展开查看更多

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

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

BASH
/etc/init.d/ssh restart
点击展开查看更多

ssh

版权声明

作者: JunYan`Blog

链接: https://www.jinjun.top/posts/59/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

评论

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键