debian12 - 修改SSH端口连接回包

2024-08-28 10:36

本文主要是介绍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

这篇关于debian12 - 修改SSH端口连接回包的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1114519

相关文章

W外链微信推广短连接怎么做?

制作微信推广链接的难点分析 一、内容创作难度 制作微信推广链接时,首先需要创作有吸引力的内容。这不仅要求内容本身有趣、有价值,还要能够激起人们的分享欲望。对于许多企业和个人来说,尤其是那些缺乏创意和写作能力的人来说,这是制作微信推广链接的一大难点。 二、精准定位难度 微信用户群体庞大,不同用户的需求和兴趣各异。因此,制作推广链接时需要精准定位目标受众,以便更有效地吸引他们点击并分享链接

Java 连接Sql sever 2008

Java 连接Sql sever 2008 /Sql sever 2008 R2 import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class TestJDBC

实例:如何统计当前主机的连接状态和连接数

统计当前主机的连接状态和连接数 在 Linux 中,可使用 ss 命令来查看主机的网络连接状态。以下是统计当前主机连接状态和连接主机数量的具体操作。 1. 统计当前主机的连接状态 使用 ss 命令结合 grep、cut、sort 和 uniq 命令来统计当前主机的 TCP 连接状态。 ss -nta | grep -v '^State' | cut -d " " -f 1 | sort |

两个月冲刺软考——访问位与修改位的题型(淘汰哪一页);内聚的类型;关于码制的知识点;地址映射的相关内容

1.访问位与修改位的题型(淘汰哪一页) 访问位:为1时表示在内存期间被访问过,为0时表示未被访问;修改位:为1时表示该页面自从被装入内存后被修改过,为0时表示未修改过。 置换页面时,最先置换访问位和修改位为00的,其次是01(没被访问但被修改过)的,之后是10(被访问了但没被修改过),最后是11。 2.内聚的类型 功能内聚:完成一个单一功能,各个部分协同工作,缺一不可。 顺序内聚:

git ssh key相关

step1、进入.ssh文件夹   (windows下 下载git客户端)   cd ~/.ssh(windows mkdir ~/.ssh) step2、配置name和email git config --global user.name "你的名称"git config --global user.email "你的邮箱" step3、生成key ssh-keygen

如何在运行时修改serialVersionUID

优质博文:IT-BLOG-CN 问题 我正在使用第三方库连接到外部系统,一切运行正常,但突然出现序列化错误 java.io.InvalidClassException: com.essbase.api.base.EssException; local class incompatible: stream classdesc serialVersionUID = 90314637791991

【Go】go连接clickhouse使用TCP协议

离开你是傻是对是错 是看破是软弱 这结果是爱是恨或者是什么 如果是种解脱 怎么会还有眷恋在我心窝 那么爱你为什么                      🎵 黄品源/莫文蔚《那么爱你为什么》 package mainimport ("context""fmt""log""time""github.com/ClickHouse/clickhouse-go/v2")func main(

nginx长连接的问题

转自: http://www.360doc.com/content/12/1108/17/1073512_246644318.shtml

NGINX轻松管理10万长连接 --- 基于2GB内存的CentOS 6.5 x86-64

转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=190176&id=4234854 一 前言 当管理大量连接时,特别是只有少量活跃连接,NGINX有比较好的CPU和RAM利用率,如今是多终端保持在线的时代,更能让NGINX发挥这个优点。本文做一个简单测试,NGINX在一个普通PC虚拟机上维护100k的HTTP

TL-Tomcat中长连接的底层源码原理实现

长连接:浏览器告诉tomcat不要将请求关掉。  如果不是长连接,tomcat响应后会告诉浏览器把这个连接关掉。    tomcat中有一个缓冲区  如果发送大批量数据后 又不处理  那么会堆积缓冲区 后面的请求会越来越慢。