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
    • 最新
    • 标签
主页 / unix / 问题

问题[key-authentication](unix)

Martin Hope
vfclists
Asked: 2020-02-11 15:34:35 +0800 CST

SSH authorized_keys 中配置的服务器端命令如何处理传入的数据?

  • 0

git 和 Gitolite 等一些实用程序可以通过修改authorized_key文件来限制 SSH 密钥可以运行的命令。

例如,Gitolite 更改会修改authorized_keys文件中的条目,因此:

command="/usr/bin/gitolite/src/gitolite-shell username",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty

由于此命令在接收端运行,它必须处理来自 SSH 连接的数据流。

像这样的命令如何处理传入的数据,例如读取传入的数据流并将其发送到使用它的任何目录或进程?

ssh key-authentication
  • 1 个回答
  • 31 Views
Martin Hope
Isaac P. Liu
Asked: 2020-02-09 11:01:38 +0800 CST

WSL ssh 到带有公钥的本地主机,但一直要求输入密码

  • 2

我试图在我的 WSL(Ubuntu 16)上设置与本地主机的公钥 ssh 连接,而无需密码登录。

但每次我一直被要求输入密码。当我使用port22时,我的密码甚至无法使用,但是当我使用其他端口(如2222)时,至少我的密码可以让我通过,但公钥仍然无法使用。

这是我使用时得到的:sudo ssh -v -p 22 localhost

    OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /home/hadoop/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/hadoop/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/hadoop/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/hadoop/.ssh/id_ecdsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.4        IBM11.1.4040.491
debug1: match: OpenSSH_5.4 IBM11.1.4040.491 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to localhost:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:jt2fTN1xeFtdB7ntfeQ5V8NnRxdDceejwwChS5hs3xw
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password
debug1: Next authentication method: password
root@localhost's password:
debug1: Authentications that can continue: password
Permission denied, please try again.
root@localhost's password:
debug1: Authentications that can continue: password
Permission denied, please try again.
root@localhost's password:
debug1: Authentications that can continue: password
debug1: No more authentication methods to try.
root@localhost: Permission denied (password).

这是 ~/.ssh 目录中所有文件的权限:

 -rw------- 1 hadoop hadoop  404 Feb  7 23:00 authorized_keys
-rw-r--r-- 1 hadoop hadoop 1675 Feb  7 22:58 id_rsa
-rw-r--r-- 1 hadoop hadoop  404 Feb  7 22:58 id_rsa.pub
-rw-r--r-- 1 hadoop hadoop 1552 Feb  8 12:38 known_hosts

这是 /etc/ssh 目录中文件的权限

    -rw------- 1 root root    404 Feb  8 01:42 authorized_keys
-rw-r--r-- 1 root root    404 Feb  8 01:55 id_rsa.pub
-rw-r--r-- 1 root root 553122 Mar  4  2019 moduli
-rw-r--r-- 1 root root   1617 Feb  8 13:27 ssh_config
-rw------- 1 root root    227 Feb  7 21:46 ssh_host_ecdsa_key
-rw-r--r-- 1 root root    182 Feb  7 21:46 ssh_host_ecdsa_key.pub
-rw------- 1 root root    411 Feb  7 21:46 ssh_host_ed25519_key
-rw-r--r-- 1 root root    102 Feb  7 21:46 ssh_host_ed25519_key.pub
-rw------- 1 root root   1679 Feb  7 21:46 ssh_host_rsa_key
-rw-r--r-- 1 root root    402 Feb  7 21:46 ssh_host_rsa_key.pub
-rw-r--r-- 1 root root    338 May 21  2019 ssh_import_id
-rw-r--r-- 1 root root   3282 Feb  8 13:33 sshd_config

这是 sshd_config 文件的内容

#       $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Port 22
Protocol 2
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::1

HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key

#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
RekeyLimit default none

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:

LoginGraceTime 2m
PermitRootLogin without-password
AllowUsers hadoop isaac root
StrictModes yes
MaxAuthTries 6
MaxSessions 10

PubkeyAuthentication yes

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
AuthorizedKeysFile      .ssh/authorized_keys .ssh/authorized_keys2

AuthorizedPrincipalsFile none

AuthorizedKeysCommand none
AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

# override default of no subsystems
Subsystem       sftp    /usr/lib/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server

这是 ssh_config 文件的内容

 # This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *

    #   ForwardAgent no
    #   ForwardX11 no
    #   ForwardX11Trusted yes
    #   PasswordAuthentication yes
    #   HostbasedAuthentication no
    #   GSSAPIAuthentication no
    #   GSSAPIDelegateCredentials no
    #   GSSAPIKeyExchange no
    #   GSSAPITrustDNS no
    #   BatchMode no
       CheckHostIP yes
       AddressFamily any
    #   ConnectTimeout 0
       StrictHostKeyChecking ask
       IdentityFile /home/hadoop/.ssh/id_rsa
    #   IdentityFile /home/hadoop/.ssh/id_dsa
       IdentityFile /home/hadoop/.ssh/id_ecdsa
    #   IdentityFile /home/hadoop/.ssh/id_ed25519
       Port 22
       Protocol 2
    #   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
    #   MACs hmac-md5,hmac-sha1,[email protected]
    #   EscapeChar ~
    #   Tunnel no
    #   TunnelDevice any:any
    #   PermitLocalCommand no
    #   VisualHostKey no
    #   ProxyCommand ssh -q -W %h:%p gateway.example.com
    #   RekeyLimit 1G 1h
        SendEnv LANG LC_*
        HashKnownHosts yes
        GSSAPIAuthentication yes

请给一些建议。

ssh key-authentication
  • 1 个回答
  • 2264 Views
Martin Hope
David West
Asked: 2020-02-08 08:36:21 +0800 CST

如何设置策略以仅在公钥具有满足要求的密码时启用公钥身份验证?

  • 0

如何设置策略以仅在公钥具有满足要求的密码时启用公钥身份验证?

目前人们用ssh-keygen. 我们希望强制创建和使用具有符合标准的密码的密钥。

谢谢。

authentication key-authentication
  • 1 个回答
  • 40 Views
Martin Hope
Noman
Asked: 2020-01-26 17:53:01 +0800 CST

卡住无法设置私钥/公钥

  • 0

所以,这就是我想要做的,我的 windows 10 将连接到远程操作系统 CentOS 7。我在 windows 上做了 ssh-keygen。然后使用 WinSCP,我将 id_rsa.pub 的内容复制到远程服务器上的 /.ssh/authorized_keys

请在屏幕截图中检查位置是否正确且权限设置是否正确:

在此处输入图像描述

这是文件夹:

在此处输入图像描述

在 Windows 上创建公钥/私钥时,我保留了默认设置:

在此处输入图像描述

它仍然卡住并要求输入密码。以下是带有 -vvv 标志的日志,这是我正在运行的命令:

C:\Users\userName>ssh -vvv -o IdentitiesOnly=yes -i C:/Users/userName/.ssh/id_rsa -p 7822 [email protected]



OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug3: Failed to open file:C:/Users/userName/.ssh/config error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname 68.66.207.180 is address
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 68.66.207.180 [68.66.207.180] port 7822.
debug1: Connection established.
debug1: identity file C:/Users/userName/.ssh/id_rsa type 0
debug3: Failed to open file:C:/Users/userName/.ssh/id_rsa-cert error:2
debug3: Failed to open file:C:/Users/userName/.ssh/id_rsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:/Users/userName/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 68.66.207.180:7822 as 'root'
debug3: put_host_port: [68.66.207.180]:7822
debug3: hostkeys_foreach: reading file "C:\\Users\\userName/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\userName/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [68.66.207.180]:7822
debug3: Failed to open file:C:/Users/userName/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
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,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],ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
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
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,ecdsa-sha2-nistp256
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
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: [email protected]
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
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:tRqKNWpPbyG+3N+r4DWb8xPkfB2uNMIXigOZGz/BLaQ
debug3: put_host_port: [68.66.207.180]:7822
debug3: put_host_port: [68.66.207.180]:7822
debug3: hostkeys_foreach: reading file "C:\\Users\\userName/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\userName/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [68.66.207.180]:7822
debug3: Failed to open file:C:/Users/userName/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug3: hostkeys_foreach: reading file "C:\\Users\\userName/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\userName/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [68.66.207.180]:7822
debug3: Failed to open file:C:/Users/userName/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug1: Host '[68.66.207.180]:7822' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\userName/.ssh/known_hosts:1
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
debug3: unable to connect to pipe \\\\.\\pipe\\openssh-ssh-agent, error: 2
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug2: key: C:/Users/userName/.ssh/id_rsa (0000018B2BFFB420), explicit
debug3: send packet: type 5
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,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:EWyaOiqiVIoJPcozJwLpQXkCTmsLAsZ502eaquZCyDw C:/Users/userName/.ssh/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,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
debug3: failed to open file:C:/dev/tty error:3
debug1: read_passphrase: can't open /dev/tty: No such file or directory
[email protected]'s password:
ssh key-authentication
  • 1 个回答
  • 3756 Views
Martin Hope
vfclists
Asked: 2020-01-12 20:48:04 +0800 CST

如果 ssh 密钥未连接到正确的端口,是否可以将其配置为拒绝连接?

  • 1

由于 sshd 服务可以侦听不同的端口,因此是否可以配置一个密钥,该密钥仅在一个端口上建立连接时才有效,而在另一个端口上无效?

我的意思是密钥在列表中出现多次,authorized_keys如果在密钥中指定的端口上进行连接,则允许连接。

这个想法是使用相同的密钥,但具有不同的command=和其他选项,以允许将相同的密钥用于不同的服务。

ssh key-authentication
  • 1 个回答
  • 92 Views
Martin Hope
Zumo de Vidrio
Asked: 2019-12-14 07:23:14 +0800 CST

带有公钥的 SSH 连接不适用于特定名称

  • 0

当尝试连接到服务器时:

ssh -i MYKEY_SSH user@IP

它提示输入密码。但是,如果我将该键重命名为任何其他名称,则连接已正确建立。

也就是说,如果我这样做:

cp MYKEY_SSH whatever_ssh

然后

ssh -i whatever_ssh user@IP

可以直接连接。

我无法弄清楚问题出在哪里。

我的本地系统中没有特定的 ssh 配置,重命名时权限也没有变化。

在不成功的 SSH 密钥连接中,调试说:

debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: [email protected]
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: key_ssh
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password

在一个成功的例子中,我看到之后它说:

debug1: Trying private key: key_ssh
debug1: Authentication succeeded (publickey).
Authenticated to IP ([IP]:22).
ssh key-authentication
  • 1 个回答
  • 1465 Views
Martin Hope
yael
Asked: 2019-08-28 11:16:57 +0800 CST

如何在对远程机器执行 ssh 以进行测试时创建远程主机标识已更改的场景

  • 0

我们想从返回的 linux 远程机器中引起状态

"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r",
"@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @\r",
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r", 

所以我们在本地/root/.ssh/known_host文件(beta机器)中更改远程机器的字符之一,以便进行此模拟

但这不会发生

当我们从 beta 机器向远程机器执行 ssh 时

ssh alpha1

我们无需获取即可访问远程机器:

"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r",
"@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @\r",
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r", 

那么如何模拟这种情况呢?

ssh key-authentication
  • 1 个回答
  • 91 Views
Martin Hope
Esoteric Eric
Asked: 2019-07-31 10:19:47 +0800 CST

只加载私钥时 ssh-copy-id 如何获取公钥?

  • 2

当我为用户加载了私钥时,我可以运行ssh-copy-id user@remotehostname并提示输入密码。当我输入正确的密码后,我现在可以使用密钥登录了。我以前总是将此命令-i <path to public key>作为参数运行,但现在意识到我不需要公钥的路径。

当我以 user@hostname 身份登录时,我会搜索 .ssh/authorized_keys 文件,并查看与我的私钥匹配的公钥,这让我感到困惑——我从未提供过公钥。

当我运行命令时,ssh-copy-id 如何知道哪个公钥与我在本地加载的私钥匹配?当我不提供授权密钥文件时,它怎么知道要添加什么?

我希望我很清楚——我一直在跑步ssh-copy-id -i <public key>,这对我来说很有意义——它登录并将公钥复制到授权的密钥文件中。但是如果我不提供公钥(即我ssh-add <private key>在运行 ssh-copy-id 之前运行),只要我加载了私钥,它仍然可以工作,而且我不明白它是如何获取公钥的。

编辑:澄清一下,我没有保留默认的 id*.pub 命名约定。因此,我在手册页中看到的关于搜索 id*.pub 的逻辑似乎并不适用。事实上,我可以创建一个名为 randompair 的密钥对,加载 randompair,将 rendompair.pub 重命名为 newname.pub,运行 ssh-copy-id,它仍然会加载正确的公钥。

查看 bash 脚本本身让我对它是如何实现这一点感到有些困惑。

ssh key-authentication
  • 2 个回答
  • 1899 Views
Martin Hope
jmunsch
Asked: 2019-07-27 09:03:31 +0800 CST

运行 nslookup 时所需的密钥不可用,挖掘

  • 0

我最近升级了我的系统,现在我看到一个非常奇怪的错误,有什么想法可以解决这个问题吗?:

nslookup 8.8.8.8
../../../../lib/isc/unix/socket.c:2135: internal_send: 192.168.43.232#53: Required key not available
../../../../lib/isc/unix/socket.c:2137: unable to convert errno to isc_result: 126: Required key not available
8.8.8.8.in-addr.arpa    name = dns.google.

Authoritative answers can be found from:

编辑:

不幸的是,我没有注意到通过软件中心应用程序完成的版本,我正在运行 Ubuntu 18.04 的变体( pop_os )

systemd-resolve --status:

Global
     DNS Servers: 192.168.43.220


Link 3 (wlp113s0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.43.232
                      2600:1014:b02f:45d5::c3

nmap -p 53 -Pn 192.168.43.232

Starting Nmap 7.60 ( https://nmap.org ) at 2019-07-26 14:00 CDT
Nmap scan report for 192.168.43.232
Host is up.

PORT   STATE    SERVICE
53/tcp filtered domain

Nmap done: 1 IP address (1 host up) scanned in 2.03 seconds

dig 8.8.8.8:

../../../../lib/isc/unix/socket.c:2135: internal_send: 192.168.43.232#53: Required key not available
../../../../lib/isc/unix/socket.c:2137: unable to convert errno to isc_result: 126: Required key not available

; <<>> DiG 9.11.3-1ubuntu1.8-Ubuntu <<>> 8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49678
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;8.8.8.8.           IN  A

;; ANSWER SECTION:
8.8.8.8.        0   IN  A   8.8.8.8

;; Query time: 6 msec
;; SERVER: 2600:1014:b02f:45d5::c3#53(2600:1014:b02f:45d5::c3)
;; WHEN: Fri Jul 26 14:03:02 CDT 2019
;; MSG SIZE  rcvd: 41

可能相关:

  • https://askubuntu.com/questions/914997/install-virtualbox-while-keeping-secure-boot
  • 无法插入“vboxdrv”:所需的密钥不可用
  • 无法使用安全启动在 Fedora 上加载 zfs 内核模块 - “必需的密钥不可用”
  • https://askubuntu.com/questions/891248/ubuntu-16-04-how-can-i-disable-secure-boot
  • 已签名的内核模块 - “未使用受信任的密钥签名”
  • http://man7.org/linux/man-pages/man2/request_key.2.html

可能的解决方案

  • 尝试解锁端口 53。
  • 我遇到了一个问题,docker-compose 对网络做了一些奇怪的事情,所以我跑了docker-compose down && docker-compose up
dns key-authentication
  • 1 个回答
  • 736 Views
Martin Hope
Stanley Yu
Asked: 2019-06-11 12:27:48 +0800 CST

SSH 不使用公钥/私钥

  • 0

我有一个系统,其中 SSH-ing 仍然要求输入密码,即使:

  1. 我的公钥authorized_keys在远程服务器上的文件中正确。
  2. 我的私钥存储id_rsa在我的.ssh目录中。
  3. 本地客户端和远程服务器上的权限是正确的。这包括主目录、.ssh目录、authorized_keys文件和密钥文件本身。
  4. SELinux 在客户端和服务器上都被禁用。

此外,/var/log/secure服务器在每次登录尝试时都会报告以下错误:

sshd[17110]: error: Could not get shadow information for <USER>

我用字符串替换了实际的用户名<USER>。

这可能是什么原因和/或如何让我的 SSH 密钥正常工作?

ssh key-authentication
  • 1 个回答
  • 1030 Views

Sidebar

Stats

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

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve