
前提・実現したいこと
機械学習初心者です。
Windows環境でVSCodeのRemote SSHを使ったSSHに失敗し、繋がりませんでした。
エラー時のログ
[19:18:53.197] Log Level: 2 [19:18:53.198] remote-ssh@0.82.1 [19:18:53.198] win32 x64 [19:18:53.204] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a2231382e3137372e34312e323439222c2275736572223a227562756e7475227d", attempt 1 [19:18:53.205] "remote.SSH.useLocalServer": false [19:18:53.205] "remote.SSH.showLoginTerminal": false [19:18:53.205] "remote.SSH.remotePlatform": {} [19:18:53.205] "remote.SSH.path": undefined [19:18:53.205] "remote.SSH.configFile": C:\Users\user\.ssh\config [19:18:53.205] "remote.SSH.useFlock": true [19:18:53.206] "remote.SSH.lockfilesInTmp": false [19:18:53.206] "remote.SSH.localServerDownload": auto [19:18:53.206] "remote.SSH.remoteServerListenOnSocket": false [19:18:53.206] "remote.SSH.showLoginTerminal": false [19:18:53.206] "remote.SSH.defaultExtensions": [] [19:18:53.206] "remote.SSH.loglevel": 2 [19:18:53.206] "remote.SSH.enableDynamicForwarding": true [19:18:53.206] "remote.SSH.enableRemoteCommand": false [19:18:53.206] "remote.SSH.serverPickPortsFromRange": {} [19:18:53.207] "remote.SSH.serverInstallPath": {} [19:18:53.225] SSH Resolver called for host: ubuntu@18.177.xx.xxx [19:18:53.225] Setting up SSH remote "18.177.xx.xxx" [19:18:53.246] Using commit id "30d9c6cd9483b2cc586687151bcbcd635f373630" and quality "stable" for server [19:18:53.249] Install and start server if needed [19:18:55.610] Checking ssh with "ssh -V" [19:18:55.686] > OpenSSH_for_Windows_8.1p1, [19:18:55.687] > LibreSSL 3.0.2 [19:18:55.697] Using SSH config file "C:\Users\user\.ssh\config" [19:18:55.697] Remote command length: 6205/8192 characters [19:18:55.697] Running script with connection command: ssh -T -D 65310 -F "C:\Users\user\.ssh\config" "ubuntu@18.177.xx.xxx" powershell [19:18:55.702] Terminal shell path: C:\windows\System32\cmd.exe [19:18:56.083] > ESC]0;C:\windows\System32\cmd.exeBEL [19:18:56.083] Got some output, clearing connection timeout [19:18:56.193] > ubuntu@18.177.xx.xxx: Permission denied (publickey). [19:18:56.206] > プロセスが、存在しないパイプに書き込もうとしました。 [19:18:57.489] "install" terminal command done [19:18:57.489] Install terminal quit with output: プロセスが、存在しないパイプに書き込もうとしました。 [19:18:57.489] Received install output: プロセスが、存在しないパイプに書き込もうとしました。 [19:18:57.491] Failed to parse remote port from server output [19:18:57.492] Resolver error: Error: at Function.Create (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.82.1\out\extension.js:1:585219) at Object.t.handleInstallOutput (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.82.1\out\extension.js:1:583871) at Object.t.tryInstall (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.82.1\out\extension.js:1:680958) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.82.1\out\extension.js:1:643905 at async Object.t.withShowDetailsEvent (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.82.1\out\extension.js:1:647221) at async Object.t.resolve (c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.82.1\out\extension.js:1:644955) at async c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-ssh-0.82.1\out\extension.js:1:727005 [19:18:57.499] ------
該当のソースコード
~/.ssh/configは下記の通りです。
Host ubuntu@18.177.xx.xxx HostName 18.177.xx.xxx User ubuntu Port 22 IdentityFile C:\Users\user\.ssh\key
Windows コマンドプロンプトからのSSH接続を確認は下記の通りです。
C:\Users\user\.ssh>ssh -i key ubuntu@18.177.xx.xxx Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 5.4.0-1078-aws x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Thu Jun 16 17:57:56 JST 2022 System load: 0.59 Processes: 171 Usage of /: 98.9% of 15.45GB Users logged in: 1 Memory usage: 81% IP address for ens5: 10.0.11.125 Swap usage: 22% => / is using 98.9% of 15.45GB * Ubuntu Pro delivers the most comprehensive open source security and compliance features. https://ubuntu.com/aws/pro 25 updates can be applied immediately. 8 of these updates are standard security updates. To see these additional updates run: apt list --upgradable New release '20.04.4 LTS' available. Run 'do-release-upgrade' to upgrade to it. Last login: Thu Jun 16 17:46:21 2022 from 39.111.19.107 ubuntu@ip-10-0-11-125:~$
WindwsのコマンドプロンプトからはSSH接続はできるため、SSH鍵や~/.ssh/configファイルに問題はなさそうでした。
試したこと
こちらのサイト(https://hitori-sekai.com/tool/error-remotessh/ )を参考にして、
VSCodeのconfigFileのPathとVSCodeのLocalServe設定を行い、再度Remote SSHで接続確認しましたが接続できませんでした。
追記
秘密鍵を作成したリモートユーザーと接続しようとしているリモートユーザーが異なるため、新たな秘密鍵公開鍵ペアを作成し、それに基づくよう設定を行おうとした。
こちらのサイト(https://qiita.com/whim0321/items/ae72b2dd5fd41beaef04) を参考にして、接続先のLinuxサーバのユーザ、IPの設定を行うとこまでできた。
しかし、ssh公開鍵のコピーする際に下記のようにエラーが生じてしまった。
C:\> scp %USERPROFILE%\.ssh\id_rsa.pub %REMOTEHOST%:~/tmp.pub ubuntu@18.177.xx.xxx: Permission denied (publickey). lost connection
追記(2)
以前の秘密鍵を使用して、サーバーに入る。
ssh -i key ubuntu@18.177.xx.xxx
新たに作成した公開鍵の確認。
ubuntu@ip:~$ cd .ssh ubuntu@ip:~/.ssh$ ls -al total 40 drwx------ 2 ubuntu ubuntu 4096 Apr 17 23:32 . drwxr-xr-x 26 ubuntu ubuntu 4096 Jun 20 00:15 .. -rw------- 1 ubuntu ubuntu 12288 Jul 1 2021 .authorized_keys.swp -rw------- 1 ubuntu ubuntu 805 Sep 4 2021 authorized_keys -rw-r--r-- 1 ubuntu ubuntu 403 Dec 6 2021 id_rsa.pub -rw------- 1 ubuntu ubuntu 1554 May 10 09:15 known_hosts -rw-r--r-- 1 ubuntu ubuntu 1110 Feb 17 13:15 known_hosts.old
作成した日付が異なるため、新しい公開鍵は入っていない。
追記(3)
Windows端末で鍵の作成、ssh -i 始めの秘密鍵 ubuntu@18.177.xx.xxx でサーバーに入る。
サーバーに、新しく作成した秘密鍵のコピーをするため
C:\> scp -i %USERPROFILE%\.ssh\新しい秘密 %REMOTEHOST%:~/tmp
を実行後、
C:\>ssh -i %REMOTEHOST% "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp"
を入力すると
Warning: Identity file %REMOTEHOST% not accessible: No such file or directory. ssh: Could not resolve hostname mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/autho: Name or service not known
とエラーが表示された。
こちらのサイト(https://deep-blog.jp/engineer/15248/ )を参考にTera Termを使用してSSH接続を試してみたが、最後の公開鍵認証によるサーバーへの接続で認証に失敗した。
ディレクトリの構造
Users──user────ssh ─────サーバーに入るのに使ったSSH鍵.pem │ └─ .ssh───────config ├── id_rsa.pub (新しく作成した公開鍵) ├── 新しく作成した秘密鍵 └── known_hosts
使用ツール
Windows 10 Home
VSCode version 1.68
Remote-SSH ver. 082.1
ご教示頂けますと幸いです。どうぞよろしくお願いいたします。













回答1件
あなたの回答
tips
プレビュー