@gits420

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

社内サーバーにアクセスできない

解決したいこと

新卒エンジニアとして入社したのですが、社内サーバーにアクセスするために、固定グローバルipアドレスと公開鍵を先輩エンジニアに渡し、インスタンス名とIPを渡され接続出来るか確認してと言われたのですが、何をしたら良いのか分かりません

1: エラーの中に"failed to open"が多く見られるのですが、これは.ssh フォルダーへの権限の設定が問題なのでしょうか?
2: 先輩からインスタンス名も頂いているのですが、これはusernameの部分に入れるものでしょうか?

発生している問題・エラー

debug3: Failed to open file:mypath/.ssh/config error:2

debug3: Failed to open file:mypath/ssh/ssh_config error:2

debug2: resolve_canonicalize: hostname (ip address) is address

debug2: ssh_connect_direct

debug1: Connecting to ip address [ip address] port 22.

debug1: Connection established.

debug1: identity file mypath\.ssh\id_rsa.pub type 0

debug3: Failed to open file:mypath/.ssh/id_rsa.pub-cert error:2

debug3: Failed to open file:mypath//.ssh/id_rsa.pub-cert.pub error:2

debug1: identity file \.ssh\id_rsa.pub-cert type -1

debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1

debug1: Remote protocol version 2.0, remote software version OpenSSH_8.7

debug1: match: OpenSSH_8.7 pat OpenSSH* compat 0x04000000

debug2: fd 3 setting O_NONBLOCK

debug1: Authenticating to IP ADDRESS as 'username'

debug3: hostkeys_foreach: reading file "/.ssh/known_hosts"

debug3: record_hostkey: found key type ECDSA in file /.ssh/known_hosts:17

debug3: load_hostkeys: loaded 1 keys from IP ADDRESS

debug3: Failed to open file:/.ssh/known_hosts2 error:2

debug3: Failed to open file:/ssh/ssh_known_hosts error:2

debug3: Failed to open file:/ssh/ssh_known_hosts2 error:2

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: debug3: Failed to open file:/.ssh/config error:2

debug3: Failed to open file:/ssh/ssh_config error:2

debug2: resolve_canonicalize: hostname IP ADDRESS is address

debug2: ssh_connect_direct

debug1: Connecting to IP ADDRESS port 22.

debug1: Connection established.

debug1: identity file \.ssh\id_rsa.pub type 0

debug3: Failed to open file:/.ssh/id_rsa.pub-cert error:2

debug3: Failed to open file:/.ssh/id_rsa.pub-cert.pub error:2

debug1: identity file \.ssh\id_rsa.pub-cert type -1

debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1

debug1: Remote protocol version 2.0, remote software version OpenSSH_8.7

debug1: match: OpenSSH_8.7 pat OpenSSH* compat 0x04000000

debug2: fd 3 setting O_NONBLOCK

debug1: Authenticating to IP ADDRESS as 'USER_NAME'

debug3: hostkeys_foreach: reading file "/.ssh/known_hosts"

debug3: record_hostkey: found key type ECDSA in file /.ssh/known_hosts:17

debug3: load_hostkeys: loaded 1 keys from IP ADDESS

debug3: Failed to open file:/.ssh/known_hosts2 error:2

debug3: Failed to open file:/ssh/ssh_known_hosts error:2

debug3: Failed to open file:/ssh/ssh_known_hosts2 error:2

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: compression ctos: none,zlib@openssh.com,zlib

debug2: compression stoc: none,zlib@openssh.com,zlib

debug2: languages ctos:

debug2: languages stoc:

debug2: first_kex_follows 0

debug2: reserved 0

debug2: peer server KEXINIT proposal

debug2: compression ctos: none,zlib@openssh.com

debug2: compression stoc: none,zlib@openssh.com

debug2: languages ctos:

debug2: languages stoc:

debug2: first_kex_follows 0

debug2: reserved 0

debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none

debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none

debug3: send packet: type 30

debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

debug3: receive packet: type 31

debug3: hostkeys_foreach: reading file "/.ssh/known_hosts"

debug3: record_hostkey: found key type ECDSA in file /.ssh/known_hosts:17

debug3: load_hostkeys: loaded 1 keys from IP ADDRESS

debug3: Failed to open file:/.ssh/known_hosts2 error:2

debug3: Failed to open file:ssh/ssh_known_hosts error:2

debug3: Failed to open file:ssh/ssh_known_hosts2 error:2

debug1: Host 'IP ADDRESS' is known and matches the ECDSA host key.

debug1: Found key in .ssh/known_hosts:17

debug3: send packet: type 21

debug2: set_newkeys: mode 1

debug1: rekey out 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 in 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

debug1: Will attempt key: \.ssh\id_rsa.pub RSA SHA256

debug2: pubkey_prepare: done

debug3: send packet: type 5

debug3: receive packet: type 7

debug1: SSH2_MSG_EXT_INFO received

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 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: \.ssh\id_rsa.pub RSA SHA256:

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.12,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c

debug2: compression ctos: none,zlib@openssh.com,zlib

debug2: compression stoc: none,zlib@openssh.com,zlib

debug2: languages ctos:

debug2: languages stoc:

debug2: first_kex_follows 0

debug2: reserved 0

debug2: peer server KEXINIT proposal

debug2: host key algorithms:

debug2: compression ctos: none,zlib@openssh.com

debug2: compression stoc: none,zlib@openssh.com

debug2: languages ctos:

debug2: languages stoc:

debug2: first_kex_follows 0

debug2: reserved

debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none

debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none

debug3: send packet: type 30

debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

debug3: receive packet: type 31

debug1: Server host key:

debug3: hostkeys_foreach: reading file ".ssh/known_hosts"

debug3: record_hostkey: found key type ECDSA in file .ssh/known_hosts:17

debug3: load_hostkeys: loaded 1 keys from IP ADDRESS

debug3: Failed to open file:/.ssh/known_hosts2 error:2

debug3: Failed to open file:ssh/ssh_known_hosts error:2

debug3: Failed to open file/ssh/ssh_known_hosts2 error:2

debug1: Host 'IP ADDRESS' is known and matches the ECDSA host key.

debug1: Found key in /.ssh/known_hosts:17

debug3: send packet: type 21

debug2: set_newkeys: mode 1

debug1: rekey out 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 in 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

debug1: Will attempt key: .ssh\id_rsa.pub RSA

debug2: pubkey_prepare: done

debug3: send packet: type 5

debug3: receive packet: type 7

debug1: SSH2_MSG_EXT_INFO received

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 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: \.ssh\id_rsa.pub explicit

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.

例)
ユーザ名@ipアドレス: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

0 likes

3Answer

どういうコマンドラインで実行していますか?おそらくは

ssh -vvv -i mypath\.ssh\id_rsa.pub <user>@<server address>

としているような気がします。id_rsa.pub は公開鍵ですが -i オプションで指定すべきは秘密鍵の方です。

また、ユーザーディレクトリ以下の .ssh に id_rsa があるなら -iオプションは必要ありません。

また、「先輩からインスタンス名も頂いているのですが、これはusernameの部分に入れるものでしょうか?」これが質問にでてくうようではユーザー名が正しいかどうかもわかりません。そこも含めて先輩に確認した方が良いでしょう。

2Like

インスタンス名とIPを渡され接続出来るか確認してと言われたのですが、何をしたら良いのか分かりません

Permission denied エラーが出てどう対応したらいいか分からないということなら、あなたがすべきは資料を読むか先輩に報告することです。


以下の記事にまとまっているように、 permission denied はあなたのマシンまたはサーバのファイルのパーミッション設定が間違っているときに出ます。サーバの場合自力ではどうにもならないので権限を持っている人の対応が必要です。

0Like

Your answer might help someone💌