Windows下链接远程服务器error:Bad owner or permissions on /.ssh/config

本文详细解析了在使用SSH连接时遇到的config文件权限错误问题,包括错误的原因及解决步骤。介绍了如何检查和修改config文件的权限,以及通过删除config文件并重新建立连接来解决问题的方法。

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

ERROR:Bad owner or permissions on /.ssh/config的原因

原因
/.ssh/下config配置文件出现错误,config文件下文件的权限分配出现了错误

1.config文件本身的权限被锁定
2.config文件代码设定出现权限不被认可的状态

解决办法
1.config文件的属性有没有被锁定有的话打开
2.重新配置config文件
配置方法
新的centos和Ubuntu下文件的配置密钥和hosts会自动分配。

因此直接删除/.ssh/下config文件就好
在cmd命令符下输入
user@IP address
系统会提示系统会建立新的链接和密钥
Are you sure you want to continue connecting (yes/no)? 
回答yes

就可以重新和服务器建立链接了
[17:04:56.015] Log Level: 2 [17:04:56.034] SSH Resolver called for "ssh-remote+183.175.12.54", attempt 1 [17:04:56.039] remote.SSH.useLocalServer = false [17:04:56.039] remote.SSH.useExecServer = true [17:04:56.039] remote.SSH.bindHost = {} [17:04:56.040] remote.SSH.showLoginTerminal = false [17:04:56.040] remote.SSH.remotePlatform = {} [17:04:56.040] remote.SSH.path = [17:04:56.040] remote.SSH.configFile = [17:04:56.042] remote.SSH.useFlock = true [17:04:56.042] remote.SSH.lockfilesInTmp = false [17:04:56.042] remote.SSH.localServerDownload = auto [17:04:56.042] remote.SSH.remoteServerListenOnSocket = false [17:04:56.042] remote.SSH.defaultExtensions = [] [17:04:56.043] remote.SSH.defaultExtensionsIfInstalledLocally = [] [17:04:56.043] remote.SSH.loglevel = 2 [17:04:56.043] remote.SSH.enableDynamicForwarding = true [17:04:56.043] remote.SSH.enableRemoteCommand = false [17:04:56.043] remote.SSH.serverPickPortsFromRange = {} [17:04:56.044] remote.SSH.serverInstallPath = {} [17:04:56.044] remote.SSH.permitPtyAllocation = false [17:04:56.044] remote.SSH.preferredLocalPortRange = undefined [17:04:56.044] remote.SSH.useCurlAndWgetConfigurationFiles = false [17:04:56.045] remote.SSH.experimental.chat = true [17:04:56.045] remote.SSH.experimental.enhancedSessionLogs = true [17:04:56.045] remote.SSH.httpProxy = {"*":""} [17:04:56.045] remote.SSH.httpsProxy = {"*":""} [17:04:56.053] VS Code version: 1.101.2 [17:04:56.053] Remote-SSH version: remote-ssh@0.120.0 [17:04:56.054] win32 x64 [17:04:56.057] SSH Resolver called for host: 183.175.12.54 [17:04:56.057] Setting up SSH remote "183.175.12.54" [17:04:56.066] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server [17:04:56.066] Extensions to install: [17:04:56.072] Install and start server if needed [17:04:57.046] Checking ssh with "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\ssh.exe -V" [17:04:57.048] Got error from ssh: spawn C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\ssh.exe ENOENT [17:04:57.048] Checking ssh with "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp\ssh.exe -V" [17:04:57.049] Got error from ssh: spawn C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp\ssh.exe ENOENT [17:04:57.049] Checking ssh with "D:\python3.13.5\Scripts\ssh.exe -V" [17:04:57.050] Got error from ssh: spawn D:\python3.13.5\Scripts\ssh.exe ENOENT [17:04:57.051] Checking ssh with "D:\python3.13.5\ssh.exe -V" [17:04:57.051] Got error from ssh: spawn D:\python3.13.5\ssh.exe ENOENT [17:04:57.051] Checking ssh with "C:\Program Files\Common Files\Oracle\Java\javapath\ssh.exe -V" [17:04:57.053] Got error from ssh: spawn C:\Program Files\Common Files\Oracle\Java\javapath\ssh.exe ENOENT [17:04:57.053] Checking ssh with "C:\Program Files (x86)\VMware\VMware Workstation\bin\ssh.exe -V" [17:04:57.054] Got error from ssh: spawn C:\Program Files (x86)\VMware\VMware Workstation\bin\ssh.exe ENOENT [17:04:57.055] Checking ssh with "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe -V" [17:04:57.056] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe ENOENT [17:04:57.056] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V" [17:04:57.057] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT [17:04:57.057] Checking ssh with "C:\WINDOWS\ssh.exe -V" [17:04:57.058] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT [17:04:57.059] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V" [17:04:57.060] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT [17:04:57.060] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V" [17:04:57.061] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT [17:04:57.061] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V" [17:04:57.109] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2 [17:04:57.113] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 61810 "183.175.12.54" sh [17:04:57.114] Generated SSH command: 'type "C:\Users\Lenovo\AppData\Local\Temp\vscode-linux-multi-line-command-183.175.12.54-514770763.sh" | "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 61810 "183.175.12.54" sh' [17:04:57.115] Using connect timeout of 17 seconds [17:04:57.116] Terminal shell path: C:\WINDOWS\System32\cmd.exe [17:04:57.390] > Bad owner or permissions on C:\\Users\\Lenovo/.ssh/config [17:04:57.390] Got some output, clearing connection timeout [17:04:57.406] > 过程试图写入的管道不存在。 [17:04:58.664] "install" terminal command done [17:04:58.665] Install terminal quit with output: 过程试图写入的管道不存在。 [17:04:58.665] Received install output: 过程试图写入的管道不存在。 [17:04:58.666] WARN: $PLATFORM is undefined in installation script output. Errors may be dropped. [17:04:58.666] Failed to parse remote port from server output [17:04:58.666] Resolver error: Error at y.Create (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:744751) at t.handleInstallOutput (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:742832) at t.tryInstall (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:865534) at async c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:824246 at async t.withShowDetailsEvent (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:827501) at async A (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:820760) at async t.resolve (c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:824898) at async c:\Users\Lenovo\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:1113660 [17:04:58.672] ------ [17:04:58.673] No hints found in the recent session. [17:04:59.210] Opening exec server for ssh-remote+183.175.12.54 [17:04:59.228] Initizing new exec server for ssh-remote+183.175.12.54 [17:04:59.228] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server [17:04:59.228] Extensions to install: [17:04:59.326] Opening exec server for ssh-remote+183.175.12.54 [17:04:59.329] Install and start server if needed [17:05:03.005] getPlatformForHost was canceled [17:05:03.005] Exec server for ssh-remote+183.175.12.54 failed: Error: 已取消连接 [17:05:03.006] Existing exec server for ssh-remote+183.175.12.54 errored (Error: 已取消连接) [17:05:03.006] Initizing new exec server for ssh-remote+183.175.12.54 [17:05:03.007] Error opening exec server for ssh-remote+183.175.12.54: Error: 已取消连接 [17:05:03.007] No hints found in the recent session. [17:05:03.007] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server [17:05:03.007] Extensions to install: [17:05:03.011] Install and start server if needed
最新发布
07-11
### 使用远程服务器连接与配置 SSH #### 1. 基本概念 SSH(Secure Shell Protocol)是一种加密网络协议,主要用于安全地访问远程计算机。它不仅提供了安全性高的终端会话功能,还支持文件传输和其他服务[^1]。 #### 2. 配置 SSH 客户端 为了成功建立到远程服务器的安全连接,需要完成以下几项基本设置: - **生成密钥对** 如果尚未创建过 SSH 密钥,则可以通过 `ssh-keygen` 工具生成公私钥对。运行如下命令即可生成默认类型的 RSA 密钥: ```bash ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 此过程会在用户目录下的 `.ssh/` 文件夹中保存两个文件:一个是私钥 (`id_rsa`) 和另一个是公钥 (`id_rsa.pub`)。注意保护好私钥文件的权限,避免被其他用户读取或修改[^2]。 - **分发公钥至目标主机** 将本地机器上的公钥追加到远程服务器中的授权键列表里去。可以手动复制粘贴或者利用专门工具如 `ssh-copy-id` 自动化这一流程。 ```bash ssh-copy-id user@remote_host ``` #### 3. 创建并编辑 SSH Config 文件 如果频繁访问多个不同的远程站点,建议编写一个简洁明了的配置文档简化日常操作。此文件通常位于 `$HOME/.ssh/config` 路径下。例如下面的例子展示了如何定义别名以便快速切换不同环境: ```plaintext Host myserver HostName example.com User admin Port 22 IdentityFile ~/.ssh/id_rsa ``` 上述片段意味着每次只需执行简单的指令就能直达指定位置而不必重复输入冗长参数组合。 #### 4. 处理常见错误消息 当尝试从 Windows 平台发起链接请求时可能会遭遇诸如“Bad owner or permissions on ...config”的警告提示。这是因为某些敏感属性未能满足严格的要求所致。解决办法之一就是调整涉及对象的所有者身份以及存取模式直到符合预期标准为止。具体做法可参照官方手册说明或者是查阅类似案例分享获取灵感。 #### 5. 替代方案——SFTP & SCP 尽管 SSH 是一种强大的交互方式,但在单纯处理资料交换需求场景下可能显得有些笨重。此时不妨考虑采用 SFTP 或者 SCP 来代替前者达成目的。两者均基于相同的底层机制运作却专注于特定用途领域表现更佳效率更高。 ```python import paramiko transport = paramiko.Transport(("hostname", port)) private_key = paramiko.RSAKey.from_private_key_file("/path/to/private/key") try: transport.connect(username="username", pkey=private_key) except Exception as e: print(f"Connection failed with error {e}") finally: transport.close() ``` 以上脚本示范了怎样借助 Python 的 Paramiko 库构建自动化解决方案从而进一步提升工作效率减少人为失误几率。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值