簡體   English   中英

如何處理 Windows 的 SSH 配置文件中的空格?

[英]How to deal with spaces in SSH config file for Windows?

I'm using Git Bash with Windows at the moment to SSH into a Linux server.

目錄中使用了一個配置文件:“C:\Users\FirstName LastName.ssh\config”

配置文件如下所示:

Host hub
    HostName 192.168.1.151
    User root
    IdentityFile ‪‪‪‪C:\Users\FirstName LastName\.ssh\hub

如您所見,IdentityFile 中的 Firstname 和 LastName 之間有一個空格字符。 這導致 Git Bash 無法讀取指定的路徑。 它打印此錯誤: /c/Users/FirstName LastName/.ssh/config line 4: garbage at end of line; "LastName\\.ssh\\hub". /c/Users/FirstName LastName/.ssh/config line 4: garbage at end of line; "LastName\\.ssh\\hub".

我嘗試使用引號來指定字符串,並且嘗試在 IdentityFile 路徑中使用 %USERPROFILE% 變量,因此沒有空格。

帶引號的解決方案導致此錯誤:

no such identity: \342\200\252\342\200\252\342\200\252\342\200\252C:\\Users\\FirstName LastName\.ssh\\hub: No such file or directory

然后問我密碼:

root@192.168.1.151's password:

%USERPROFILE% 的解決方案給了我這個錯誤:

percent_expand: unknown key %U

所以我基本上被困在這里,關於如何解決這個問題的任何想法?

因此,在為 IdentityFile 使用引號時,我實際上是正確地解決了這個問題。 問題是,當我將路徑(我從 Windows Explorer 中的文件屬性復制)粘貼到配置文件中以定義 IdentityFile 時 - 有一些字符對編輯器不可見。 這些字符使 Git Bash 中的 SSH 客戶端感到困惑。 意外字符出現在復制路徑的開頭。

Windows 有時很古怪:/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM