前提・実現したいこと
機械学習初心者です。
WinSCP、Tera Termでは、ssh接続することができたのですが、
コマンドプロンプト、VSCodeのRemote SSHを使ったSSHに失敗し、繋がりませんでした。
おそらくポート設定が上手くいっておらず、/etc/ssh/sshd_config を変更しなくてはいけないのですが、なくなっている状態です。
ご教示頂けますと幸いです。どうぞよろしくお願いいたします。
エラー、エラー時のログ
コマンドプロンプトでは、
ssh: connect to host IPアドレス port 22: Connection refused
と表示されました。
VSCodeのRemote SSHでは、
[21:35:18.296] Log Level: 2 [21:35:18.297] remote-ssh@0.82.1 [21:35:18.297] win32 x64 [21:35:18.302] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a2231382e3137372e34312e323439222c2275736572223a227562756e7475227d", attempt 1 [21:35:18.303] "remote.SSH.useLocalServer": false [21:35:18.303] "remote.SSH.showLoginTerminal": false [21:35:18.303] "remote.SSH.remotePlatform": {"IP":"linux"} [21:35:18.303] "remote.SSH.path": undefined [21:35:18.303] "remote.SSH.configFile": C:\Users\user\.ssh\config [21:35:18.304] "remote.SSH.useFlock": true [21:35:18.304] "remote.SSH.lockfilesInTmp": false [21:35:18.304] "remote.SSH.localServerDownload": auto [21:35:18.304] "remote.SSH.remoteServerListenOnSocket": false [21:35:18.304] "remote.SSH.showLoginTerminal": false [21:35:18.304] "remote.SSH.defaultExtensions": [] [21:35:18.304] "remote.SSH.loglevel": 2 [21:35:18.304] "remote.SSH.enableDynamicForwarding": true [21:35:18.304] "remote.SSH.enableRemoteCommand": false [21:35:18.304] "remote.SSH.serverPickPortsFromRange": {} [21:35:18.304] "remote.SSH.serverInstallPath": {} [21:35:18.324] SSH Resolver called for host: ubuntu@IP [21:35:18.324] Setting up SSH remote "IP" [21:35:18.347] Using commit id "30d9c6cd9483b2cc586687151bcbcd635f373630" and quality "stable" for server [21:35:18.352] Install and start server if needed [21:35:18.355] Checking ssh with "ssh -V" [21:35:18.397] > OpenSSH_for_Windows_8.1p1, [21:35:18.398] > LibreSSL 3.0.2 [21:35:18.402] Using SSH config file "C:\Users\user\.ssh\config" [21:35:18.403] Running script with connection command: ssh -T -D 55769 -F "C:\Users\user\.ssh\config" "ubuntu@18.177.41.249" bash [21:35:18.405] Terminal shell path: C:\windows\System32\cmd.exe [21:35:18.727] > ]0;C:\windows\System32\cmd.exe [21:35:18.728] Got some output, clearing connection timeout [21:35:21.057] > ssh: connect to host IP port 22: Connection refused [21:35:21.075] > プロセスが、存在しないパイプに書き込もうとしました。 [21:35:22.361] "install" terminal command done [21:35:22.362] Install terminal quit with output: プロセスが、存在しないパイプに書き込もうとしました。 [21:35:22.362] Received install output: プロセスが、存在しないパイプに書き込もうとしました。 [21:35:22.363] Failed to parse remote port from server output [21:35:22.364] 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 [21:35:22.371] ------
と表示されました。
該当のソースコード
コマンドプロンプトでは下記の通りです。
ssh -i 鍵 ubuntu@18.177.41.xxx
~/.ssh/configは下記の通りです。
Host ubuntu@IP HostName IP User ubuntu Port 50022 IdentityFile C:\Users\user\.ssh\秘密鍵
追記
ssh/sshd_config の中身です。
# Package generated configuration file # See the sshd_config(5) manpage for details # What ports, IPs and protocols we listen for Port 50022 # Use these options to restrict which interfaces/protocols sshd will bind to ListenAddress 18.177.xx.xxx ListenAddress ::1 Protocol 2 HostKeys for protocol version 2 #HostKey /etc/ssh/ssh_host_rsa_key #HostKey /etc/ssh/ssh_host_ecdsa_key #HostKey /etc/ssh/ssh_host_ed25519_key #Privilege Separation is turned on for security UsePrivilegeSeparation yes # Lifetime and size of ephemeral version 1 server key KeyRegenerationInterval 3600 ServerKeyBits 1024 # Logging SyslogFacility AUTH LogLevel INFO # Authentication: LoginGraceTime 120 PermitRootLogin no StrictModes yes RSAAuthentication yes PubkeyAuthentication yes #AuthorizedKeysFile %h/.ssh/authorized_keys # Don't read the user's ~/.rhosts and ~/.shosts files IgnoreRhosts yes # For this to work you will also need host keys in /etc/ssh_known_hosts RhostsRSAAuthentication no # similar for protocol version 2 HostbasedAuthentication no # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication #IgnoreUserKnownHosts yes # To enable empty passwords, change to yes (NOT RECOMMENDED) PermitEmptyPasswords no # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no # Change to no to disable tunnelled clear text passwords #PasswordAuthentication yes # Kerberos options #KerberosAuthentication no #KerberosGetAFSToken no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes # GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes X11Forwarding yes X11DisplayOffset 10 PrintMotd no PrintLastLog yes TCPKeepAlive yes #UseLogin no #MaxStartups 10:30:60 #Banner /etc/issue.net # Allow client to pass locale environment variables #AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server # 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 UseDNS no
追記(2)
ディレクトリの構造
ubuntur───────ssh ─────sshd_cinfig │ └─ sshd_config.old │ └─ id_rsa.pub │ └─ id_ecdsa │ └─ id_ecdsa.pub │ └─ id_ed25519 │ └─ id_ed25519.pub │ └─ .ssh───────.authorized_keys.swp ├──authorized_keys ├──known_hosts └── known_hosts.old
追記(3)
コマンドプロンプトは
ssh -i 鍵 ubuntu@18.177.41.xxx -p 50022
でポート指定のコードに変更したことによってssh接続することができました。
しかし、VSCodeでは変わらずポートを50022に指定したにもかかわらず、
22ポートを接続することができないとエラーが返ってきます。
(サーバーの22ポートが閉じているため)
また、 id_rsa、id_ecdsa、id_ed25519 などが作成は
sshd -t
でこれらのファイルが無いため作成してくださいとエラーが返ってきたにもかからわず、
ssh-keygen -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key
などで作成してみると既に存在しますが上書きしますか?と返ってきました。
なお、上書きしてもsshフォルダ内にssh_host_rsa_key、/ssh_host_ecdsa_key、ssh_host_ed25519_keyは作成されていませんでした。
そのため、sshd -t では変わらずエラーが起こりました。
使用ツール
Windows 10 Home
VSCode version 1.68
Remote-SSH ver. 082.1
回答2件
あなたの回答
tips
プレビュー