SSHに接続するようにgpg-agentを設定しましたが、何らかの理由でデバイスアドレスを使用して接続することはできません。存在する~/.ssh/config追加しました
Host openwrt
Hostname 192.168.1.1
User root
今使用中ssh openwrt
ssh 192.168.1.1
OpenSSH_8.6p1, OpenSSL 1.1.1k 25 Mar 2021
debug1: Reading configuration data /home/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type 0
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/user/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: identity file /home/user/.ssh/id_ed25519_sk type -1
debug1: identity file /home/user/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/user/.ssh/id_xmss type -1
debug1: identity file /home/user/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
debug1: Remote protocol version 2.0, remote software version dropbear
debug1: compat_banner: no match: dropbear
debug1: Authenticating to 192.168.1.1:22 as 'user'
debug1: load_hostkeys: fopen /home/user/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-rsa SHA256:8BU0dCiyV/HSOZyyThViiuLyIQtIyQIQC5d/slYYJts
debug1: load_hostkeys: fopen /home/user/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '192.168.1.1' is known and matches the RSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: (none) RSA SHA256:dGSaK9m1A06YkSEnnLYHt9eHb02JfMeBaKp34SuwPf8 agent
debug1: Will attempt key: /home/user/.ssh/id_rsa RSA SHA256:NUxAd9IHzP1O4GoEUBED1RcPW06JusvfUVIJpLJK754
debug1: Will attempt key: /home/user/.ssh/id_dsa
debug1: Will attempt key: /home/user/.ssh/id_ecdsa
debug1: Will attempt key: /home/user/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/user/.ssh/id_ed25519
debug1: Will attempt key: /home/user/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/user/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: (none) RSA SHA256:dGSaK9m1A06YkSEnnLYHt9eHb02JfMeBaKp34SuwPf8 agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: /home/user/.ssh/id_rsa RSA SHA256:NUxAd9IHzP1O4GoEUBED1RcPW06JusvfUVIJpLJK754
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: Trying private key: /home/user/.ssh/id_ed25519_sk
debug1: Trying private key: /home/user/.ssh/id_xmss
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
両方の方法が機能する前に、この問題をどのように解決できますか?
答え1
を使用すると、ssh 192.168.1.1
現在ログインしているユーザーに接続します。このユーザーはリモートシステムにアクセスする権限がなく、ログから明らかです。
[email protected]: Permission denied (publickey).
IPアドレスを使用するには、接続する正確なユーザーも指定する必要があります。
ssh [email protected]
または、192.168.1.1
SSH設定に次のエントリがあることを確認してください。
Host openwrt 192.168.1.1
HostName 192.168.1.1
User root
上記の構成エントリを作成した方法では、2つの別々のホストが同じセクションを共有できます。Host
文字列にワイルドカードを使用することもできます(参照man ssh_config
、しかしこの特定の問題にはあまり役に立ちません)。
これは、対応するSSH設定を使用するアカウントとまったく同じように機能しますssh 192.168.1.1
。ssh openwrt
(セキュリティ対策として、私は個人的にすべてのシステムでSSH経由のrootログインを許可しません。代わりに、権限のないユーザーとしてログインしてから、または同等のツールを使用して特権タスクにsudo
アクセスします。)