LINUX开启ssh服务,报错:ssh: connect to host 192.168.6.129 port 22: Connection refused

本文解决在Ubuntu系统中使用ssh localhost命令时遇到的Connection refused错误。该问题通常由于未安装或未启动SSH server引起。文中提供了检查sshd进程状态、启动SSH server及安装openssh-server的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused

 

造成这个错误的原因可能是ssh-server未安装或者未启动。ubuntu 11.10 默认安装openssh-client,但是木有安装server

 

运行 ps -e | grep ssh,查看是否有sshd进程

 

如果没有,说明server没启动,通过 /etc/init.d/ssh -start 启动server进程,如果提示ssh不存在 那么就是没安装server

 

通过 sudo apt-get install openssh-server命令安装即可

http://asyty.iteye.com/blog/1440141

[16:00:08.942] Log Level: 2 [16:00:08.952] SSH Resolver called for "ssh-remote+ubuntu", attempt 1 [16:00:08.953] "remote.SSH.useLocalServer": false [16:00:08.953] "remote.SSH.useExecServer": true [16:00:08.953] "remote.SSH.showLoginTerminal": true [16:00:08.953] "remote.SSH.remotePlatform": {} [16:00:08.953] "remote.SSH.path": undefined [16:00:08.953] "remote.SSH.configFile": undefined [16:00:08.953] "remote.SSH.useFlock": true [16:00:08.953] "remote.SSH.lockfilesInTmp": false [16:00:08.953] "remote.SSH.localServerDownload": auto [16:00:08.953] "remote.SSH.remoteServerListenOnSocket": false [16:00:08.953] "remote.SSH.showLoginTerminal": true [16:00:08.953] "remote.SSH.defaultExtensions": [] [16:00:08.953] "remote.SSH.loglevel": 2 [16:00:08.953] "remote.SSH.enableDynamicForwarding": true [16:00:08.953] "remote.SSH.enableRemoteCommand": false [16:00:08.953] "remote.SSH.serverPickPortsFromRange": {} [16:00:08.953] "remote.SSH.serverInstallPath": {} [16:00:08.953] "remote.SSH.permitPtyAllocation": false [16:00:08.953] "remote.SSH.preferredLocalPortRange: undefined [16:00:08.953] "remote.SSH.useCurlAndWgetConfigurationFiles: false [16:00:08.958] SSH Resolver called for host: ubuntu [16:00:08.958] Setting up SSH remote "ubuntu" [16:00:08.967] VS Code version: 1.95.3 [16:00:08.967] Remote-SSH version: remote-ssh@0.115.1 [16:00:08.967] win32 x64 [16:00:08.968] Using commit id "f1a4fb101478ce6ec82fe9627c43efbf9e98c813" and quality "stable" for server [16:00:08.971] Script variables: { "InstallExitCode.24": "AlreadyInProgress", "InstallExitCode.25": "ServerDownloadFailed", "InstallExitCode.26": "NoDownloaderAvailable", "InstallExitCode.27": "UnsupportedArch", "InstallExitCode.28": "StatusCheckFailed", "InstallExitCode.29": "NeedInsidersArch", "InstallExitCode.30": "NoDownloaderAvailableForStatusCheck", "InstallExitCode.31": "ServerTransferFailed", "InstallExitCode.32": "ServerFailedToStart", "InstallExitCode.33": "NeedInsidersWindows", "InstallExitCode.34": "CreateInstallDirFailed", "InstallExitCode.35": "UnsupportedPlatform", "InstallExitCode.36": "ServerTerminatedCVE20201416", "InstallExitCode.37": "UnpackFailed", "InstallExitCode.38": "ChangeDirFailed", "InstallExitCode.AlreadyInProgress": "24", "InstallExitCode.ServerDownloadFailed": "25", "InstallExitCode.NoDownloaderAvailable": "26", "InstallExitCode.NoDownloaderAvailableForStatusCheck": "30", "InstallExitCode.UnsupportedArch": "27", "InstallExitCode.StatusCheckFailed": "28", "InstallExitCode.NeedInsidersArch": "29", "InstallExitCode.ServerTransferFailed": "31", "InstallExitCode.ServerFailedToStart": "32", "InstallExitCode.NeedInsidersWindows": "33", "InstallExitCode.CreateInstallDirFailed": "34", "InstallExitCode.UnsupportedPlatform": "35", "InstallExitCode.ServerTerminatedCVE20201416": "36", "InstallExitCode.UnpackFailed": "37", "InstallExitCode.ChangeDirFailed": "38", "InstallUnpackCode.Success": "success", "InstallUnpackCode.Error": "error", "InstallUnpackCode.MissingFiles": "missingFiles", "uuid": "be116060ecd4", "startMarker": "be116060ecd4: running", "commitId": "f1a4fb101478ce6ec82fe9627c43efbf9e98c813", "quality": "stable", "token": "111a111a-a111-1111-111a-111aaa11a11a", "vscodeAgentFolder": "$HOME/.vscode-server", "allowClientDownload": "1", "forceClientDownload": "0", "cliNameInArchive": "code", "ignoreWgetConfigFlag": " --no-config ", "ignoreCurlConfigFlag": " --disable ", "wgetTriesSegment": "--tries=1", "listenArgs": "--on-host=127.0.0.1 --on-port", "getDownloadServerStartTrigger": "be116060ecd4:trigger_server_download", "getDownloadServerEndTrigger": "be116060ecd4:trigger_server_download_end", "getProgressDownloading": "be116060ecd4%%1%%", "getProgressInstalling": "be116060ecd4%%2%%" } [16:00:08.973] Install and start server if needed [16:00:10.216] Checking ssh with "D:\xuniji\bin\ssh.exe -V" [16:00:10.218] Got error from ssh: spawn D:\xuniji\bin\ssh.exe ENOENT [16:00:10.218] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V" [16:00:10.218] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT [16:00:10.218] Checking ssh with "C:\WINDOWS\ssh.exe -V" [16:00:10.219] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT [16:00:10.219] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V" [16:00:10.220] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT [16:00:10.220] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V" [16:00:10.220] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT [16:00:10.220] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V" [16:00:10.255] > OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 [16:00:10.259] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 54906 ubuntu sh [16:00:10.260] Generated SSH command: 'type "C:\Users\admin\AppData\Local\Temp\vscode-linux-multi-line-command-ubuntu-92598382.sh" | "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 54906 ubuntu sh' [16:00:10.261] Using connect timeout of 17 seconds [16:00:10.261] Terminal shell path: C:\WINDOWS\System32\cmd.exe [16:00:10.453] > [?9001h[?1004h > > > > > > > > > > > > ]0;C:\WINDOWS\System32\cmd.exe [16:00:10.453] Got some output, clearing connection timeout [16:00:21.848] > ssh: connect to host ubuntu port 22: Connection refused [16:00:21.862] > 过程试图写入的管道不存在。 [16:00:23.128] "install" terminal command done [16:00:23.128] Install terminal quit with output: 过程试图写入的管道不存在。 [16:00:23.128] Received install output: 过程试图写入的管道不存在。 [16:00:23.129] Failed to parse remote port from server output [16:00:23.130] Resolver error: Error: at v.Create (c:\Users\admin\.vscode\extensions\ms-vscode-remote.remote-ssh-0.115.1\out\extension.js:2:493431) at t.handleInstallOutput (c:\Users\admin\.vscode\extensions\ms-vscode-remote.remote-ssh-0.115.1\out\extension.js:2:490753) at t.tryInstall (c:\Users\admin\.vscode\extensions\ms-vscode-remote.remote-ssh-0.115.1\out\extension.js:2:608797) at async c:\Users\admin\.vscode\extensions\ms-vscode-remote.remote-ssh-0.115.1\out\extension.js:2:568008 at async t.withShowDetailsEvent (c:\Users\admin\.vscode\extensions\ms-vscode-remote.remote-ssh-0.115.1\out\extension.js:2:571256) at async P (c:\Users\admin\.vscode\extensions\ms-vscode-remote.remote-ssh-0.115.1\out\extension.js:2:564794) at async t.resolve (c:\Users\admin\.vscode\extensions\ms-vscode-remote.remote-ssh-0.115.1\out\extension.js:2:568667) at async c:\Users\admin\.vscode\extensions\ms-vscode-remote.remote-ssh-0.115.1\out\extension.js:2:839059 [16:00:23.133] ------分析一下错误原因
最新发布
07-31
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值