I'm using Git Bash with Windows at the moment to SSH into a Linux server.
A config file is being used at the directory: "C:\Users\FirstName LastName.ssh\config"
The config file looks like this:
Host hub
HostName 192.168.1.151
User root
IdentityFile C:\Users\FirstName LastName\.ssh\hub
As you can see there is a space character in between Firstname and LastName at IdentityFile. That leads Git Bash to not being able to read the path specified. It prints this error: /c/Users/FirstName LastName/.ssh/config line 4: garbage at end of line; "LastName\\.ssh\\hub".
I've tried to use quotes to specify string and I've tried using %USERPROFILE% variable in the IdentityFile Path so there are no spaces.
The solution with quotes leads to this error:
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
And then asks me for the password:
root@192.168.1.151's password:
The solution with %USERPROFILE% gives me this error:
percent_expand: unknown key %U
So I'm stuck here basically, any ideas on how to fix this?
So, I was actually solving this correctly when using quotes for IdentityFile. The problem was that when I had pasted the path(which I copied from properties of the file inside Windows Explorer) into the config file to define IdentityFile - there was some characters that were invisible to the editor. These characters made the SSH Client in Git Bash confused. The unexpected characters were present at the start of the copied path.
Windows is wack sometimes :/
Usually, running this command on the file will remove the invisible characters:
sed -i '1s/^.*#//;s/\r$//' {FILENAME}