当前位置: 首页 > news >正文

debian12 - 修改SSH端口连接回包

文章目录

    • debian12 - 修改SSH端口连接回包
    • 概述
    • 笔记
    • 先猜猜回包是哪个程序回的
    • 去下载对应版本的openssh代码工程
    • 用telnet测试的效果
    • @todo 关于ssh状态为active(start)的原因
    • END

debian12 - 修改SSH端口连接回包

概述

和同学讨论问题。
他说,用telnet去连接SSH端口,回包内容能看出系统版本和SSH版本。
用原装的debian12 + win10上的telnet连接了一下,确实如此。

telnet 192.168.236.133 22
SSH-2.0-OpenSSH_9.2p1 Debian-2+deb12u1 // 这个连接时发送给客户段的信息有点敏感。
// 光标停在上一行首,不停闪烁
// 自己主动按下回车键,断开连接。Invalid SSH identification string.遗失对主机的连接。

笔记

想做个实验,尝试修改用telnet连接SSH端口时的回包,隐藏linux系统版本和SSH版本这些敏感信息。
用真机和虚拟机没区别,且用虚拟机做实验,可以回到自己保存的快照。
先切到安装完debian12原版且配置好了SSH的快照。
在这里插入图片描述

先猜猜回包是哪个程序回的

大概率是openssh回的,因为这是ssh的服务。连接,通讯都是openssh处理的。
看看openssh的版本。

lostspeed@debian12d4x64:~$ ssh -V
OpenSSH_9.2p1 Debian-2+deb12u1, OpenSSL 3.0.11 19 Sep 2023

去下载对应版本的openssh代码工程

最方便的方法是用apt-get, 不用自己导出去找,直接从debian源中就能下载相同版本的源码工程。

lostspeed@debian12d4x64:~$ pwd
/home/lostspeedmkdir ./src
cd ./src## 先确认安装依赖的软件
## 所有要先附加安装的依赖软件,都是根据后续操作报错提示来安装的。
sudo apt-get install dpkg-dev## 用apt-get自动下载系统中对应的软件源码包
sudo apt-get source openssh
## 。。。
dpkg-source: info: applying CVE-2023-51384.patch
dpkg-source: info: applying CVE-2023-51385.patch
W: 由于文件'openssh_9.2p1-2+deb12u2.dsc'无法被用户'_apt'访问,已脱离沙盒并提权为根用户来进行下载。 - pkgAcquire::Run (13: 权限不够)
lostspeed@debian12d4x64:~/src$ ls
openssh-9.2p1  openssh_9.2p1-2+deb12u2.debian.tar.xz  openssh_9.2p1-2+deb12u2.dsc  openssh_9.2p1.orig.tar.gz  openssh_9.2p1.orig.tar.gz.asc
## 下载最后,有个报错,说openssh_9.2p1-2+deb12u2.dsc不可用,但是东西都下载全了,忽略这个错误。

代码已经下载到了本地,版本和正在用的openssh相同。

源码目录已经自动解开了

开始配置,make, make install
配置时,如果错误,根据报错提示,将依赖的软件包装上。

cd openssh-9.2p1
lostspeed@debian12d4x64:~/src/openssh-9.2p1$ ls -l configure*
-rwxr-xr-x 1 root root 649619 202322日 configure
-rw-r--r-- 1 root root 160383  8月26日 22:57 configure.ac## 配置时,就不要加预设路径了,等安装完,改系统中的ssh服务的配置文件去。
## 如果安装的路径和系统中现有的ssh不同,也不要紧,服务程序都是配置文件指定的。
## sudo ./configure
## configure: error: ./configure.ac newer than configure, run autoreconf## sudo apt-get install autotools-dev
## sudo apt list *auto*conf*
sudo apt-get install autoconf
sudo autoupdate
sudo autoreconf
## sudo ./configure
## sudo apt list *zlib*
sudo apt-get install zlib1g-dev
## sudo apt list *openssl*
sudo apt install libssl-dev
sudo ./configure
sudo make
sudo make install
## /usr/local/etc/sshd_config line 86: Unsupported option UsePAM安装报错。
修改/home/lostspeed/src/openssh-9.2p1/sshd_config,注释掉UsePAM选项, 重新安装
sudo vi /home/lostspeed/src/openssh-9.2p1/sshd_config

在这里插入图片描述

sudo make clean
sudo make
sudo rm /usr/local/share/man/man5/authorized_keys.5 /usr/local/etc/sshd_config /usr/local/etc/ssh_config /usr/local/etc/moduli
clear && sudo make install## 记录一下安装提示,方便后面改ssh服务脚本
Makefile:688: warning: ignoring prerequisites on suffix rule definition
(cd openbsd-compat && make)
make[1]: 进入目录“/home/lostspeed/src/openssh-9.2p1/openbsd-compat”
make[1]: 对“all”无需做任何事。
make[1]: 离开目录“/home/lostspeed/src/openssh-9.2p1/openbsd-compat”
/usr/bin/mkdir -p /usr/local/bin
/usr/bin/mkdir -p /usr/local/sbin
/usr/bin/mkdir -p /usr/local/share/man/man1
/usr/bin/mkdir -p /usr/local/share/man/man5
/usr/bin/mkdir -p /usr/local/share/man/man8
/usr/bin/mkdir -p /usr/local/libexec
/usr/bin/mkdir -p -m 0755 /var/empty
/usr/bin/install -c -m 0755 -s ssh /usr/local/bin/ssh
/usr/bin/install -c -m 0755 -s scp /usr/local/bin/scp
/usr/bin/install -c -m 0755 -s ssh-add /usr/local/bin/ssh-add
/usr/bin/install -c -m 0755 -s ssh-agent /usr/local/bin/ssh-agent
/usr/bin/install -c -m 0755 -s ssh-keygen /usr/local/bin/ssh-keygen
/usr/bin/install -c -m 0755 -s ssh-keyscan /usr/local/bin/ssh-keyscan
/usr/bin/install -c -m 0755 -s sshd /usr/local/sbin/sshd
/usr/bin/install -c -m 4711 -s ssh-keysign /usr/local/libexec/ssh-keysign
/usr/bin/install -c -m 0755 -s ssh-pkcs11-helper /usr/local/libexec/ssh-pkcs11-helper
/usr/bin/install -c -m 0755 -s ssh-sk-helper /usr/local/libexec/ssh-sk-helper
/usr/bin/install -c -m 0755 -s sftp /usr/local/bin/sftp
/usr/bin/install -c -m 0755 -s sftp-server /usr/local/libexec/sftp-server
/usr/bin/install -c -m 644 ssh.1.out /usr/local/share/man/man1/ssh.1
/usr/bin/install -c -m 644 scp.1.out /usr/local/share/man/man1/scp.1
/usr/bin/install -c -m 644 ssh-add.1.out /usr/local/share/man/man1/ssh-add.1
/usr/bin/install -c -m 644 ssh-agent.1.out /usr/local/share/man/man1/ssh-agent.1
/usr/bin/install -c -m 644 ssh-keygen.1.out /usr/local/share/man/man1/ssh-keygen.1
/usr/bin/install -c -m 644 ssh-keyscan.1.out /usr/local/share/man/man1/ssh-keyscan.1
/usr/bin/install -c -m 644 moduli.5.out /usr/local/share/man/man5/moduli.5
/usr/bin/install -c -m 644 sshd_config.5.out /usr/local/share/man/man5/sshd_config.5
/usr/bin/install -c -m 644 ssh_config.5.out /usr/local/share/man/man5/ssh_config.5
/usr/bin/install -c -m 644 sshd.8.out /usr/local/share/man/man8/sshd.8
ln -s ../man8/sshd.8 /usr/local/share/man/man5/authorized_keys.5
/usr/bin/install -c -m 644 sftp.1.out /usr/local/share/man/man1/sftp.1
/usr/bin/install -c -m 644 sftp-server.8.out /usr/local/share/man/man8/sftp-server.8
/usr/bin/install -c -m 644 ssh-keysign.8.out /usr/local/share/man/man8/ssh-keysign.8
/usr/bin/install -c -m 644 ssh-pkcs11-helper.8.out /usr/local/share/man/man8/ssh-pkcs11-helper.8
/usr/bin/install -c -m 644 ssh-sk-helper.8.out /usr/local/share/man/man8/ssh-sk-helper.8
/usr/bin/mkdir -p /usr/local/etc
/usr/local/sbin/sshd -t -f /usr/local/etc/sshd_config

找一下系统中的sshd

lostspeed@debian12d4x64:~/src/openssh-9.2p1$ whereis sshd
sshd: /usr/sbin/sshd /usr/local/sbin/sshd /usr/share/man/man8/sshd.8.gz
## /usr/sbin/sshd 是系统中原始的
## /usr/local/sbin/sshd 是咱自己编译安装的

看一下ssh服务在哪里?

clear && systemctl status ssh

在这里插入图片描述
可知:
服务脚本为/lib/systemd/system/ssh.service
服务程序是 /usr/sbin/sshd

现在去修改/lib/systemd/system/ssh.service,来运行我们自己编译安装的sshd
sudo vi /lib/systemd/system/ssh.service
原始内容如下:

[Unit]
Description=OpenBSD Secure Shell server
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755[Install]
WantedBy=multi-user.target
Alias=sshd.service

修改如下

[Unit]
Description=OpenBSD Secure Shell server
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target auditd.service
# ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
# /etc/ssh/ => /usr/local/etc/
ConditionPathExists=!/usr/local/etc/sshd_not_to_be_run[Service]
EnvironmentFile=-/etc/default/ssh
# /usr/sbin/sshd => /usr/local/sbin/sshd
ExecStartPre=/usr/local/sbin/sshd -t
ExecStart=/usr/local/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/local/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755[Install]
WantedBy=multi-user.target
Alias=sshd.service

关闭ssh服务/重启ssh服务

sudo systemctl status ssh
sudo systemctl daemon-reload
sudo systemctl status ssh ## 此时旧位置的服务已经停了
sudo systemctl stop ssh
sudo systemctl start ssh
sudo systemctl status ssh ## 此时启动的已经是新服务

在这里插入图片描述

为了拷贝文件方便,将ssh配置改为可以root登录。

lostspeed@debian12d4x64:~/src$ whereis sshd_config
sshd_config: /usr/local/etc/sshd_config /usr/share/man/man5/sshd_config.5.gz
sudo vi /usr/local/etc/sshd_config

修改内容如下:

#PermitRootLogin prohibit-password
PermitRootLogin yes#PasswordAuthentication yes
PasswordAuthentication yes

重启ssh服务

sudo systemctl restart ssh
sudo systemctl status ssh

然后启动windTerm,用root用户登录。

## 传文件不方便,改变一下分组
sudo chown lostspeed:lostspeed openssh-9.2p1

openssh用的是syslog, 为了查看日志,需要安装rsyslog.
安装syslog(debian12 - rsyslog的安装/配置/使用)
查看实时日志 sudo tail -f /var/log/syslog

现在用telnet去连接debian12, 看看回的啥?日志里面记录的啥

telnet 192.168.236.133 22
SSH-2.0-OpenSSH_9.2p1 Debian-2+deb12u1Invalid SSH identification string.遗失对主机的连接。

/var/log/syslog 内容无变化。
那看看 /var/log/auth.log
sudo tail -f /var/log/auth.log
现在用telnet去连接debian12, 看看回的啥?日志里面记录的啥

2024-08-27T21:12:34.853546+08:00 debian12d4x64 sshd[14872]: error: kex_exchange_identification: client sent invalid protocol identifier ""
2024-08-27T21:12:34.854058+08:00 debian12d4x64 sshd[14872]: banner exchange: Connection from 192.168.236.1 port 58166: invalid format

有反应,但是显示的日志级别比较高。
改一下syslog日志的显示级别。

sudo systemctl status syslog

在这里插入图片描述
可以看到syslog的配置文件为rsyslog.conf
查一下这个配置文件的位置。

lostspeed@debian12d4x64:~/src/openssh-9.2p1$ whereis rsyslog.conf
rsyslog.conf: /etc/rsyslog.conf /usr/share/man/man5/rsyslog.conf.5.gz

查到rsyslog的配置文件位置 = /etc/rsyslog.conf
修改配置

sudo vi /etc/rsyslog.conf

/etc/rsyslog.conf 不需要改
暂时不知道syslog日志的显示级别怎么改,先这么用吧。
我自己做实验时(debian12 - rsyslog的安装/配置/使用), 每个级别的日志都能显示在/var/log/syslog中。
不知道为啥openssh的日志不显示在/var/log/syslog中。

好像是要配置sshd的日志显示级别才行,并不是配置syslog(因为syslog配置,默认全部级别的日志都是显示的)。
配置sshd日志

备注 - 如果自己还要make install, 还是要改工程目录下的sshd_config。
因为make install时,会将工程中的sshd_config覆盖到系统中的/usr/local/etc/sshd_config

lostspeed@debian12d4x64:~/src/openssh-9.2p1$ whereis sshd_config
sshd_config: /usr/local/etc/sshd_config /usr/share/man/man5/sshd_config.5.gz配置文件为 /usr/local/etc/sshd_config
sudo vi /usr/local/etc/sshd_config

在这里插入图片描述

sudo systemctl restart ssh
sudo systemctl status ssh
sudo tail -f /var/log/syslog现在将源码目录拷贝到研发本本上的win10, 研究一下该改哪里?sudo tail -f /var/log/auth.log
现在用telnet去连接debian12, 看看回的啥?日志里面记录的啥```bash
2024-08-27T21:12:34.853546+08:00 debian12d4x64 sshd[14872]: error: kex_exchange_identification: client sent invalid protocol identifier ""
2024-08-27T21:12:34.854058+08:00 debian12d4x64 sshd[14872]: banner exchange: Connection from 192.168.236.1 port 58166: invalid format

在这里插入图片描述

在sshd.c的main()入口附近,加一句print, 防止运行的不是我们改的最新版本。(这是错误的想法和做法)
这是服务,程序里面不能随便加printf, 但是可以加日志。
原因是:
应该是有命令行传值的用法。
这里有害, 不能加printf, 影响SFTP的建立
sshd.c的main()入口加了printf, 会使客户端(windTerm)无法建立SFTP连接。
还好改一改试一试,否则将对的东西改成错的,真不好找。

在这里插入图片描述
在日志初始化后面,再加一句日志,方便分清我们修改的版本。
在这里插入图片描述
将这个版本上传到debian12, 编译安装。

sudo make
sudo rm /usr/local/share/man/man5/authorized_keys.5 /usr/local/etc/sshd_config /usr/local/etc/ssh_config /usr/local/etc/moduli
clear && sudo make install
## 先实时查看日志 sudo tail -f /var/log/syslog
sudo systemctl restart ssh

在这里插入图片描述
现在可以确定,我们修改的sshd在被运行。

下面就可以看看SSH端口连接回包处理在哪里?
用win10的telnet去连接debian12的SSH端口。
/var/log/syslog 没动静。
那么看 auth.log

sudo tail -f /var/log/auth.log

用win10的telnet去连接debian12的SSH端口。
看到下面的日志。

2024-08-27T22:11:12.876836+08:00 debian12d4x64 sshd[15434]: sshd.c log init ok
2024-08-27T22:11:19.656429+08:00 debian12d4x64 sshd[15434]: error: kex_exchange_identification: client sent invalid protocol identifier ""
2024-08-27T22:11:19.656619+08:00 debian12d4x64 sshd[15434]: banner exchange: Connection from 192.168.236.1 port 59798: invalid format

结合auth.log中的日志信息和telnet上的回包信息,在源码中查找关心的提示字符串
在这里插入图片描述
在这个函数中翻了一下,函数名称为kex_exchange_identification(), 这里包含回包的字符串信息的逻辑。
就改这个函数,直接将回包敏感值不给telnet客户端, 加一些syslog日志,用logit()函数,记录INFO级别的日志信息。
修改后kex_exchange_identification()如下:
实质性的修改就是屏蔽了SSH版本回包,其他地方就是加几句日志确认一下流程

/** Sends our identification string and waits for the peer's. Will block for* up to timeout_ms (or indefinitely if timeout_ms <= 0).* Returns on 0 success or a ssherr.h code on failure.*/
int
kex_exchange_identification(struct ssh *ssh, int timeout_ms,int debian_banner, const char *version_addendum)
{int remote_major, remote_minor, mismatch, oerrno = 0;size_t len, n;int r, expect_nl;u_char c;struct sshbuf *our_version = ssh->kex->server ?ssh->kex->server_version : ssh->kex->client_version;struct sshbuf *peer_version = ssh->kex->server ?ssh->kex->client_version : ssh->kex->server_version;char *our_version_string = NULL, *peer_version_string = NULL;char *cp, *remote_version = NULL;logit(">> kex_exchange_identification()"); // add by ls/* Prepare and send our banner */sshbuf_reset(our_version);if (version_addendum != NULL && *version_addendum == '\0')version_addendum = NULL;if ((r = sshbuf_putf(our_version, "SSH-%d.%d-%.100s%s%s\r\n",PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2,debian_banner ? SSH_RELEASE : SSH_RELEASE_MINIMUM,version_addendum == NULL ? "" : " ",version_addendum == NULL ? "" : version_addendum)) != 0) {oerrno = errno;error_fr(r, "sshbuf_putf");goto out;}// modify by ls// 这里发版本包的敏感信息给telnet客户端// 直接注释掉,不发给客户端了// 或者直接改为其他信息(e.g. "welcome to home")// 但是sshbuf数据结构的赋值,现在暂时还没做实验,就先不发送
//	if (atomicio(vwrite, ssh_packet_get_connection_out(ssh),
//	    sshbuf_mutable_ptr(our_version),
//	    sshbuf_len(our_version)) != sshbuf_len(our_version)) {
//		oerrno = errno;
//		debug_f("write: %.100s", strerror(errno));
//		r = SSH_ERR_SYSTEM_ERROR;
//		goto out;
//	}if ((r = sshbuf_consume_end(our_version, 2)) != 0) { /* trim \r\n */oerrno = errno;error_fr(r, "sshbuf_consume_end");goto out;}our_version_string = sshbuf_dup_string(our_version);if (our_version_string == NULL) {error_f("sshbuf_dup_string failed");r = SSH_ERR_ALLOC_FAIL;goto out;}debug("Local version string %.100s", our_version_string);logit("kex.c Local version string %.100s", our_version_string); // add by ls/* Read other side's version identification. */for (n = 0; ; n++) {if (n >= SSH_MAX_PRE_BANNER_LINES) {send_error(ssh, "No SSH identification string ""received.");error_f("No SSH version received in first %u lines ""from server", SSH_MAX_PRE_BANNER_LINES);r = SSH_ERR_INVALID_FORMAT;goto out;}sshbuf_reset(peer_version);expect_nl = 0;for (;;) {if (timeout_ms > 0) {r = waitrfd(ssh_packet_get_connection_in(ssh),&timeout_ms);if (r == -1 && errno == ETIMEDOUT) {send_error(ssh, "Timed out waiting ""for SSH identification string.");error("Connection timed out during ""banner exchange");r = SSH_ERR_CONN_TIMEOUT;goto out;} else if (r == -1) {oerrno = errno;error_f("%s", strerror(errno));r = SSH_ERR_SYSTEM_ERROR;goto out;}}len = atomicio(read, ssh_packet_get_connection_in(ssh),&c, 1);if (len != 1 && errno == EPIPE) {error_f("Connection closed by remote host");r = SSH_ERR_CONN_CLOSED;goto out;} else if (len != 1) {oerrno = errno;error_f("read: %.100s", strerror(errno));r = SSH_ERR_SYSTEM_ERROR;goto out;}if (c == '\r') {expect_nl = 1;continue;}if (c == '\n')break;if (c == '\0' || expect_nl) {error_f("banner line contains invalid ""characters");goto invalid;}if ((r = sshbuf_put_u8(peer_version, c)) != 0) {oerrno = errno;error_fr(r, "sshbuf_put");goto out;}if (sshbuf_len(peer_version) > SSH_MAX_BANNER_LEN) {error_f("banner line too long");goto invalid;}}/* Is this an actual protocol banner? */if (sshbuf_len(peer_version) > 4 &&memcmp(sshbuf_ptr(peer_version), "SSH-", 4) == 0)break;/* If not, then just log the line and continue */if ((cp = sshbuf_dup_string(peer_version)) == NULL) {error_f("sshbuf_dup_string failed");r = SSH_ERR_ALLOC_FAIL;goto out;}/* Do not accept lines before the SSH ident from a client */if (ssh->kex->server) {error_f("client sent invalid protocol identifier ""\"%.256s\"", cp);free(cp);goto invalid;}debug_f("banner line %zu: %s", n, cp);free(cp);}peer_version_string = sshbuf_dup_string(peer_version);if (peer_version_string == NULL)error_f("sshbuf_dup_string failed");/* XXX must be same size for sscanf */if ((remote_version = calloc(1, sshbuf_len(peer_version))) == NULL) {error_f("calloc failed");r = SSH_ERR_ALLOC_FAIL;goto out;}/** Check that the versions match.  In future this might accept* several versions and set appropriate flags to handle them.*/if (sscanf(peer_version_string, "SSH-%d.%d-%[^\n]\n",&remote_major, &remote_minor, remote_version) != 3) {error("Bad remote protocol version identification: '%.100s'",peer_version_string);invalid:send_error(ssh, "Invalid SSH identification string.");logit("Invalid SSH identification string."); // add by lsr = SSH_ERR_INVALID_FORMAT;goto out;}debug("Remote protocol version %d.%d, remote software version %.100s",remote_major, remote_minor, remote_version);compat_banner(ssh, remote_version);mismatch = 0;switch (remote_major) {case 2:break;case 1:if (remote_minor != 99)mismatch = 1;break;default:mismatch = 1;break;}if (mismatch) {error("Protocol major versions differ: %d vs. %d",PROTOCOL_MAJOR_2, remote_major);send_error(ssh, "Protocol major versions differ.");r = SSH_ERR_NO_PROTOCOL_VERSION;goto out;}if (ssh->kex->server && (ssh->compat & SSH_BUG_PROBE) != 0) {logit("probed from %s port %d with %s.  Don't panic.",ssh_remote_ipaddr(ssh), ssh_remote_port(ssh),peer_version_string);r = SSH_ERR_CONN_CLOSED; /* XXX */goto out;}if (ssh->kex->server && (ssh->compat & SSH_BUG_SCANNER) != 0) {logit("scanned from %s port %d with %s.  Don't panic.",ssh_remote_ipaddr(ssh), ssh_remote_port(ssh),peer_version_string);r = SSH_ERR_CONN_CLOSED; /* XXX */goto out;}if ((ssh->compat & SSH_BUG_RSASIGMD5) != 0) {logit("Remote version \"%.100s\" uses unsafe RSA signature ""scheme; disabling use of RSA keys", remote_version);}/* success */r = 0;out:free(our_version_string);free(peer_version_string);free(remote_version);if (r == SSH_ERR_SYSTEM_ERROR)errno = oerrno;return r;
}

将kex.c更新到debian12中的src/openssh-9.2p1源码目录,重新编译安装。
每次在研发本本上修改后,最好是一股脑都传到debian12. 一定要在本地改,不要倒过来。防止漏改漏传漏归档。
值得注意的是工程目录中的sshd_config要修改成自己想要的(e.g. root)

sudo make
sudo rm /usr/local/share/man/man5/authorized_keys.5 /usr/local/etc/sshd_config /usr/local/etc/ssh_config /usr/local/etc/moduli
clear && sudo make installsudo systemctl restart ssh
sudo tail -f /var/log/auth.log

如果在实验中,发现自己改的没效果,需要确认一下,是否启动ssh服务时,启动的是自己改的sshd. make install时,是否覆盖的是ssh服务中指定的位置和名称。
我中间就遇到了改来改去没效果,但是改的地方也对。最后发现,make install的位置和ssh服务中的位置不一样:P

将改过的openssh-9.2p1,通过windTerm整个拖到debian12, 更新到debian12中去编译/安装。

sudo systemctl stop ssh
sudo ./configure --prefix=/usr/sbin
## sudo make clean
sudo make clean
sudo make
## sudo make uninstall
sudo rm /usr/sbin/share/man/man5/authorized_keys.5 /usr/sbin/etc/ssh_config /usr/sbin/etc/sshd_config /usr/sbin/etc/moduli /usr/sbin/sshd
sudo make installsudo systemctl start ssh

用telnet连接SSH端口看了一下效果,好使,已经将连接时的敏感信息(SSH版本号 + OS版本号)不显示了。

用telnet测试的效果

在这里插入图片描述
回车执行命令
在这里插入图片描述
未修改前,这里显示的是敏感信息(SSH版本 + OS版本)。
修改后,这里不显示东西。可以根据情况,在这里显示一个伪造的信息。
再回车一下。
在这里插入图片描述
再回车一下,就断开连接了。
这里显示的信息就是原版SSHD的实现。
可以根据情况,将这里的提示去掉,或者伪造一个信息返回给telnet.

@todo 关于ssh状态为active(start)的原因

在debian12中的命令行,执行 sudo systemctl start ssh, 回车后不返回。所以查询状态时,为active(start).
这个状态不太正常,但是能用,不耽误干活。
具体原因,有时间再查一下。
如果原版源码编译完,状态可以是active(start), 那好查。因为问题都出在自己改的这一部分。
如果原版也是active(start), 那就不好搞了,毕竟不是原作者。

END

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • RISC-V全志D1sCVBS套件
  • JAVA之MAC详解以及子线程MDC传递
  • 飞书怎么关联任意两段话
  • 中医文化推广者魏玉龙任国家医药卫生行业继续教育培训基地培训中心主任
  • Java自定义异常处理
  • 关于类与构造函数继承的小挑战
  • bhyve安装win10第一篇:如何下载Win10 iso安装光盘
  • Java, 将 csv 中空值用上一行的值填充
  • c++异常处理(c++11版)与智能指针 SmartPtr 的应用(主讲shared_ptr浅实现)
  • “双指针”算法下篇
  • zabbix监控进程、日志、主从(状态、延迟)
  • spring security怎么解决用户的权限问题
  • 速盾:海外cdn加速可以https加密吗?
  • 数据库集群技术
  • Flask-RESTFul 之 RESTFul 的响应处理 之定制返回的 json格式
  • 【许晓笛】 EOS 智能合约案例解析(3)
  • canvas 五子棋游戏
  •  D - 粉碎叛乱F - 其他起义
  • JS创建对象模式及其对象原型链探究(一):Object模式
  • PHP的Ev教程三(Periodic watcher)
  • React Native移动开发实战-3-实现页面间的数据传递
  • vue从入门到进阶:计算属性computed与侦听器watch(三)
  • vue数据传递--我有特殊的实现技巧
  • 回顾 Swift 多平台移植进度 #2
  • 开发基于以太坊智能合约的DApp
  • 使用Envoy 作Sidecar Proxy的微服务模式-4.Prometheus的指标收集
  • 突破自己的技术思维
  • 微信小程序设置上一页数据
  • 协程
  • # Swust 12th acm 邀请赛# [ K ] 三角形判定 [题解]
  • #### golang中【堆】的使用及底层 ####
  • #13 yum、编译安装与sed命令的使用
  • #NOIP 2014# day.1 T3 飞扬的小鸟 bird
  • (1)(1.13) SiK无线电高级配置(六)
  • (zz)子曾经曰过:先有司,赦小过,举贤才
  • (创新)基于VMD-CNN-BiLSTM的电力负荷预测—代码+数据
  • (力扣题库)跳跃游戏II(c++)
  • (生成器)yield与(迭代器)generator
  • (十五)使用Nexus创建Maven私服
  • (小白学Java)Java简介和基本配置
  • (转)Android中使用ormlite实现持久化(一)--HelloOrmLite
  • (转)德国人的记事本
  • (转)真正的中国天气api接口xml,json(求加精) ...
  • .Net 8.0 新的变化
  • .NET Compact Framework 3.5 支持 WCF 的子集
  • .net core 外观者设计模式 实现,多种支付选择
  • .net core开源商城系统源码,支持可视化布局小程序
  • .Net程序帮助文档制作
  • .NET开源的一个小而快并且功能强大的 Windows 动态桌面软件 - DreamScene2
  • .NET框架设计—常被忽视的C#设计技巧
  • @Autowired注解的实现原理
  • @四年级家长,这条香港优才计划+华侨生联考捷径,一定要看!
  • []利用定点式具实现:文件读取,完成不同进制之间的
  • [120_移动开发Android]008_android开发之Pull操作xml文件
  • [AAuto]给百宝箱增加娱乐功能