AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题

问题[sshd](computer)

Martin Hope
BoZenKhaa
Asked: 2020-11-24 02:49:23 +0800 CST

sshd_config 选项:`PermitTunnel` 与 `AllowTcpForwarding`

  • 7

我无法理解文件PermitTunnel中的选项sshd_config。此选项与AllowTcpForwarding? 拥有PermitTunnel no似乎对连接到服务器的隧道没有任何影响。

男人这样说PermitTunnel:

 Specifies whether tun(4) device forwarding is allowed.  The argument must be yes,
             point-to-point (layer 3), ethernet (layer 2), or no.  Specifying yes permits both
             point-to-point and ethernet.  The default is no.

             Independent of this setting, the permissions of the selected tun(4) device must allow access
             to the user.

但这对我来说意义不大。

debian sshd
  • 1 个回答
  • 7618 Views
Martin Hope
Ross Rogers
Asked: 2020-06-25 12:23:26 +0800 CST

当 ssh 命令消失时,如何在 ssh 服务器上关闭远程 ssh 隧道端口?

  • 6

我正在创建从客户端到服务器的隧道,例如:

ssh -N \
  -o ConnectTimeout=9 \
  -o ServerAliveInterval=5 \
  -o ServerAliveCountMax=1 \
  -o ExitOnForwardFailure=yes \
  -R 0.0.0.0:10021:localhost:22  \
  [email protected]

如果我拔下客户端以太网,它会超时:

Timeout, server example.com not responding.

如果我立即尝试重新连接,它会说:

Error: remote port forwarding failed for listen port 10021

这是因为服务器仍然显示:

sudo netstat -tnlpa | grep 10021
tcp        0      0 0.0.0.0:10021           0.0.0.0:*               LISTEN      30173/sshd: foo

sshd客户端连接消失后,如何让服务器关闭端口?

ssh sshd
  • 1 个回答
  • 430 Views
Martin Hope
HappyDog
Asked: 2020-05-03 00:42:53 +0800 CST

sshd 是否硬编码为需要 root 访问权限?

  • 7

我正在尝试以非 root 用户身份运行 SSH 守护程序,因为我想在我没有 root 访问权限的服务器上提供对我们 Git 存储库的 SSH 访问权限。我已经使用自定义配置和本地证书运行它,但登录当前无法正常工作。

我正在使用以下版本sshd:

OpenSSH_7.4p1,OpenSSL 1.0.2k-fips 2017 年 1 月 26 日

在这个阶段,我不寻求有关配置等方面的帮助(如有必要,我将发布单独的问题)。在我投入更多时间之前,我只想知道是否存在硬编码限制,这意味着这是不可能的。

SSH 守护程序中是否有任何硬限制阻止它作为非 root 用户成功使用?

linux sshd
  • 1 个回答
  • 431 Views
Martin Hope
0laf
Asked: 2020-04-26 15:10:59 +0800 CST

sshd config:仅允许来自同一专用网络内的连接

  • 6

我想配置 sshd 以便接受同一专用网络内的任何用户,但拒绝其他所有人。

示例:我的 IP 地址是 192.168.1.159,所以应该允许网络 192.168.1.0 内的任何人。

背景:

目前我正在配置一个嵌入式设备映像,并考虑将其添加为一个小的附加安全措施。该映像将在不同位置的设备上运行。IP 地址将通过 DHCP 分配,每个系统可能连接到不同配置的专用网络(如 10.0.1.0、192.168.100.0、...)。

所以我想,理想情况下,我想要的是:

DenyUsers *
Match Address OWN_DEVICE_ADDRESS/24
    AllowUsers *

然而,阅读手册页sshd_config我找不到这种可能性。

所以我最终想到了接受所有具有专用网络 ip v4 地址的用户,并将以下内容附加到/etc/ssh/sshd_config:

Match Address 192.168.0.0/16,172.16.0.0/12,10.0.0.0/8
        AllowUsers *

DenyUsers *

然而,测试这个(通过输出systemctl status sshd)表明,即使我在同一个网络中,该DenyUsers规则仍然是最重要的:

Apr 25 23:37:43 host sshd[27733]: User test from 192.168.1.166 not allowed because listed in DenyUsers *

所以我想我没能理解DenyUsers. 你们能帮帮我吗?

openssh sshd
  • 2 个回答
  • 1668 Views
Martin Hope
Martin James
Asked: 2019-04-12 06:59:42 +0800 CST

sshd 不会接受密钥,但前提是命名为 id_rsa

  • 2

sshd 遇到一个奇怪的问题,它将接受一个密钥,但前提是它不是名称“id_rsa”

[root@login01 .ssh]# cp id_rsa idrsa 
[root@login01 .ssh]# md5sum id_rsa idrsa
e45bc86220892d9212819704cdf116fb  id_rsa
e45bc86220892d9212819704cdf116fb  idrsa
[root@login01 .ssh]# ssh -i id_rsa mgmt01
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
[root@login01 .ssh]# ssh -i idrsa mgmt01
Last login: Wed Apr 10 16:46:49 2019 from login01-ib
[root@mgmt01 ~]#

以前有人遇到过这个问题吗?我检查了所有权限,它们看起来很好。在这个问题上挠我的头。

对于冗长:

我们得到的坏钥匙

[root@login01 .ssh]# ssh -i id_rsa mgmt01 -vvv
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "mgmt01" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to mgmt01 [10.1.1.252] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to mgmt01:22 as 'root'
debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:5
debug3: load_hostkeys: loaded 1 keys from mgmt01
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],[email protected],ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:iN76ArdjVn/wZlIOL66artv0q+xOcTInSyG+29JKd7w
debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:5
debug3: load_hostkeys: loaded 1 keys from mgmt01
debug3: hostkeys_foreach: reading file "/root/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:4
debug3: load_hostkeys: loaded 1 keys from 10.1.1.252
debug1: Host 'mgmt01' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:5
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: id_rsa (0x560301c1b190), explicit
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-keyex
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-keyex
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

我们得到的好钥匙:

debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: idrsa
debug3: sign_and_send_pubkey: RSA SHA256:dnizM1DopxxMTYUZzfQFx+ZKSuESOuT1ob1xaJicQI0
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to mgmt01 ([10.1.1.252]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 91
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env HOSTNAME
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env HISTSIZE
debug3: Ignored env SSH_CLIENT
debug3: Ignored env PERL5LIB
debug3: Ignored env QTDIR
debug3: Ignored env QTINC
debug3: Ignored env PERL_MB_OPT
debug3: Ignored env SSH_TTY
debug3: Ignored env QT_GRAPHICSSYSTEM_CHECKED
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env MAIL
debug3: Ignored env PATH
debug3: Ignored env PWD
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env MODULEPATH
debug3: Ignored env LOADEDMODULES
debug3: Ignored env KDEDIRS
debug3: Ignored env HISTCONTROL
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env PERL_LOCAL_LIB_ROOT
debug3: Ignored env LOGNAME
debug3: Ignored env QTLIB
debug3: Ignored env CVS_RSH
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env MODULESHOME
debug3: Ignored env LESSOPEN
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env QT_PLUGIN_PATH
debug3: Ignored env PERL_MM_OPT
debug3: Ignored env BASH_FUNC_module()
debug3: Ignored env _
debug3: Ignored env OLDPWD
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0

对于证书,我在 config 和 /etc/ssh 中看不到以下内容;

HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
AuthorizedKeysFile  .ssh/authorized_keys

[root@mgmt01 ssh]# ll
total 608
-rw-r--r--. 1 root root     581843 Apr 10  2018 moduli
-rw-r--r--. 1 root root       2304 Apr 10 16:19 ssh_config
-rw-------. 1 root root       4431 Apr 10 16:24 sshd_config
-rw-r-----  1 root ssh_keys    227 Mar 29 12:41 ssh_host_ecdsa_key
-rw-r--r--  1 root root        162 Mar 29 12:41 ssh_host_ecdsa_key.pub
-rw-r-----  1 root ssh_keys    387 Mar 29 12:41 ssh_host_ed25519_key
-rw-r--r--  1 root root         82 Mar 29 12:41 ssh_host_ed25519_key.pub
-rw-r-----  1 root ssh_keys   1675 Mar 29 12:41 ssh_host_rsa_key
-rw-r--r--  1 root root        382 Mar 29 12:41 ssh_host_rsa_key.pub

我不确定后者是否与您的问题特别相关。

linux sshd
  • 1 个回答
  • 1305 Views
Martin Hope
Boyan Atanasov
Asked: 2019-04-06 03:41:48 +0800 CST

如果顶级会话打开,SSH 拒绝超时 [Linux]

  • 1

如果我 ssh 到服务器并且我打开顶部数据包正在通过网络发送,那么正常的 ssh 超时(因为空闲)将不起作用。
这意味着如果用户正在运行顶级进程,则 ssh 连接可以永远保持打开状态。

有没有办法在一定时间后强制 ssh 超时(或断开连接),以避免仅仅因为顶部打开就永远保持连接?

更新: 场景是人们在服务器打开顶部的 ssh 并且只要他们不关闭自己的顶部 ssh 将永远保持打开状态,这意味着它可以多次完成并且当我登录到服务器并执行“w " 命令(显示谁登录了)有许多 ssh 会话打开超过几周

ssh linux sshd
  • 2 个回答
  • 702 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve