Debian 11 安装并开启SSH服务实现允许root用户使用SecureCRT远程登录

本文档详细介绍了如何在Debian11虚拟机中安装SSH服务,包括更新系统源、安装SSH、启动与检查SSH状态、可选安装VIM编辑器、备份SSH配置文件、编辑配置文件以及重启SSH服务。最后,通过远程登录软件SecureCRT SSH进行连接验证。
摘要由CSDN通过智能技术生成

虚拟机安装完成Debian11系统后,系统默认是没有安装SSH服务,如需要开启远程登录则需要安装相应的服务。登录系统后切换至Root用户身份并执行下面相关操作。

一、更新Debian系统数据软件源

apt-get update

二、安装SSH 服务

apt-get install -y ssh

安装完成ssh 服务默认是开启的,手动开启命令

/etc/init.d/ssh start

三、查看ssh服务状态

/etc/init.d/ssh status

执行结果: 

root@debian:~# /etc/init.d/ssh status
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-03-11 10:47:15 CST; 2min 23s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 1781 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 1782 (sshd)
      Tasks: 1 (limit: 2285)
     Memory: 4.1M
        CPU: 118ms
     CGroup: /system.slice/ssh.service
             └─1782 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

3月 11 10:47:15 debian systemd[1]: ssh.service: Found left-over process 17…ing.
3月 11 10:47:15 debian systemd[1]: This usually indicates unclean terminat…ies.
3月 11 10:47:15 debian systemd[1]: ssh.service: Found left-over process 17…ing.
3月 11 10:47:15 debian systemd[1]: This usually indicates unclean terminat…ies.
3月 11 10:47:15 debian sshd[1782]: Server listening on 0.0.0.0 port 22.
3月 11 10:47:15 debian sshd[1782]: Server listening on :: port 22.
3月 11 10:47:15 debian systemd[1]: Started OpenBSD Secure Shell server.
3月 11 10:47:23 debian sshd[1743]: Failed password for root from 172.18.18…ssh2
3月 11 10:47:31 debian sshd[1791]: Accepted password for root from 172.18.…ssh2
3月 11 10:47:31 debian sshd[1791]: pam_unix(sshd:session): session opened …d=0)
Hint: Some lines were ellipsized, use -l to show in full.

四、 安装VIM进行编辑(可选)

apt-get install -y vim

五、备份 SSH 配置文件 

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

六、编辑 SSH 配置文件 

 利用VIM 编辑配置文件,把以下代码对 /etc/ssh/sshd_config 文件内容进行替换。

vim /etc/ssh/sshd_config

利用命令 more /etc/ssh/sshd_config |grep -v "^#" |grep -v "^$"  查看文件内容是否与下面一致,不一致则改成一致。

Include /etc/ssh/sshd_config.d/*.conf
Port 22
PermitRootLogin yes
PasswordAuthentication yes
PermitEmptyPasswords no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem       sftp    /usr/lib/openssh/sftp-server

七、重启 SSH 服务 

/etc/init.d/ssh restart

 然后可以利用远程登录软件(SecureCRT SSH)进行相关登录。

 

  • 8
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

网络达人丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值