I use Portable Git x64 on Windows. I run everything thought Git Bash. I need to ssh to a server which is reachable only via HTTP proxy. Authentication for server is via pubkey, authentication for proxy is via password, usernames are different. My ~/.ssh/config:
Host server
Hostname server_hostname
User server_username
IdentityFile ~/.ssh/id_rsa
ProxyCommand /c/PortableGit/mingw64/bin/connect.exe -H proxy_username#proxy_ip:12345 %h %p
The problem starts when ssh tries to pop-up the window where you need to enter a password for the HTTP proxy, log from ssh -vvv server:
$ ssh -vvv server
OpenSSH_7.9p1, OpenSSL 1.1.1a 20 Nov 2018
debug1: Reading configuration data /c/Users/username/.ssh/config
debug1: /c/Users/username/.ssh/config line 1: Applying options for server
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Executing proxy command: exec /c/PortableGit/mingw64/bin/connect.exe -H proxy_username#proxy_ip:12345 server_hostname 22
debug1: identity file /c/Users/username/.ssh/id_rsa type 0
debug1: identity file /c/Users/username/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
'C:\PortableGit\mingw64\libexec\git-core\git-gui--askpass' is not recognized as an internal or external command,
operable program or batch file.
FATAL: Cannot decide password for proxy authentication.ssh_exchange_identification: Connection closed by remote host
git-gui--askpass is there, but for some reason it's not picked up by ssh. Running file 'C:\PortableGit\mingw64\libexec\git-core\git-gui--askpass' gives:
$ file 'C:\PortableGit\mingw64\libexec\git-core\git-gui--askpass'
C:\PortableGit\mingw64\libexec\git-core\git-gui--askpass: POSIX shell script, ASCII text executable
Content of the git-gui--askpass is identical to https://github.com/git/git/blob/3bab5d56259722843359702bc27111475437ad2a/git-gui/git-gui--askpass
I tried to run this script via command line, it works fine:
Also, I tried to specify another program as SSH_ASKPASS=/mingw64/libexec/git-core/git-askpass.exe (which I assume a stupid thing to do). This does not work either:
...
fatal: failed to acquire credentials.
I tried to supply a password in ~/.ssh/config as:
ProxyCommand /c/PortableGit/mingw64/bin/connect.exe -H proxy_username:proxy_password#proxy_ip:12345 %h %p
^^^^^^^^^^^^^^^
but this is ignored by ssh.
Besides, I tried to connect via MobaXterm and this works completely fine -- I've been asked for a proxy password and after entering it I am connected. Also, after connecting in MobaXterm I can connect in command line since the proxy does not ask for a password for some time. But for a different reason I cannot use MobaXterm.
Any ideas on how to make it work?
Utility connect.exe works with HTTP_PROXY_USER and HTTP_PROXY_PASSWORD environment variables. Solution found in source code
Try keeping your password in your ~/.ssh/config file and add
unset SSH_ASKPASS
To your .bashprofile
To ssh into a remote station I do the following:
ssh -L 4001:connect.iop.kcl.ac.uk:4000 username1#cana.host.institution
I'm then asked for a password which I enter, and I then do:
ssh -YX username2#otherserver.other.institution
and am asked for another password, after which I am where I want to be.
I want to set this up in vs code using the Remote-SSH extension but am running into difficulty
When I try and add the first step (ssh -L 4001:connect.iop.kcl.ac.uk:4000 username1#cana.host.institution), my config file looks as follows:
Host cana.iop.kcl.ac.uk
HostName cana.iop.kcl.ac.uk
LocalForward 4001:connect.iop.kcl.ac.uk:4000
User dmzromc
But when I try and connect I get the following error:
[16:23:45.992] Log Level: 3
[16:23:45.993] remote-ssh#0.49.0
[16:23:45.994] darwin x64
[16:23:45.995] SSH Resolver called for "ssh-remote+cana.host.institution", attempt 1
[16:23:45.995] SSH Resolver called for host: cana.host.institution
[16:23:45.995] Setting up SSH remote "cana.host.institution"
[16:23:46.020] Using commit id "78a4c91400152c0f27ba4d363eb56d2835f9903a" and quality "stable" for server
[16:23:46.023] Install and start server if needed
[16:23:46.031] Checking ssh with "ssh -V"
[16:23:46.071] > OpenSSH_7.9p1, LibreSSL 2.7.3
[16:23:46.075] Running script with connection command: ssh -T -D 55893 -o ConnectTimeout=15 cana.iop.kcl.ac.uk bash
[16:23:46.364] > /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.364] Got some output, clearing connection timeout
[16:23:46.835] "install" terminal command done
[16:23:46.835] Install terminal quit with output: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.836] Received install output: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.837] Stopped parsing output early. Remaining text: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.837] Failed to parse remote port from server output
[16:23:46.838] Resolver error:
[16:23:46.842] ------
Any advice much appreciated
I had the same issue when forwarding a database port and fixed it by manually editing my ssh config as follows:
BEFORE (using the problematic config that VSCode auto generates)
Host mysshhost
HostName mysshhost
LocalForward 5432:mydatabaseservername:5432
User myuserid
AFTER (works for me)
Host mysshhost
HostName mysshhost
LocalForward localhost:5432 mydatabaseservername:5432
User myuserid
So in your case, the config should look something like:
Host cana.iop.kcl.ac.uk
HostName cana.iop.kcl.ac.uk
LocalForward localhost:4001 connect.iop.kcl.ac.uk:4000
User dmzromc
So I'm using the "Remote - SSH" plugin in VSCode to connect to my VPS and edit my code. I lost the connection, then had to hard-reset it after 30+ min. Now I can't access it with VSCode anymore [putty works] and get Could not establish connection to "[vps-ip]". Permission denied (publickey,password). when starting VSCode in ssh up or when reloading the connection.
I also get this log every time.
What would I have to do, to get this to work normally again?
Here is the log I replaced some stuff with [...]
[18:42:52.792] Log Level: 2
[18:42:52.795] remote-ssh#0.50.0
[18:42:52.795] win32 x64
[18:42:52.797] SSH Resolver called for "ssh-remote+[vps-ip]", attempt 1
[18:42:52.797] SSH Resolver called for host: [vps-ip]
[18:42:52.798] Setting up SSH remote "[vpsip]"
[18:42:52.801] Acquiring local install lock: C:\Users\[myname]\AppData\Local\Temp\vscode-remote-ssh-[vps-ip]-install.lock
[18:42:52.816] Looking for existing server data file at c:\Users\[myname]\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-[vps-ip]-[id]\data.json
[18:42:52.817] Using commit id "[id]" and quality "stable" for server
[18:42:52.817] Install and start server if needed
[18:42:52.820] Checking ssh with "ssh -V"
[18:42:52.875] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[18:42:52.876] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[18:42:52.917] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[18:42:52.917] Checking ssh with "C:\Program Files\Git\usr\bin\ssh.exe -V"
[18:42:52.993] > OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
[18:42:52.994] askpass server listening on \\.\pipe\vscode-ssh-askpass-[askpass]-sock
[18:42:52.995] Spawning local server with {"ipcHandlePath":"\\\\.\\pipe\\vscode-ssh-askpass-[askpass]-sock","sshCommand":"C:\\Program Files\\Git\\usr\\bin\\ssh.exe","sshArgs":["-v","-T","-D","55323","[vps-ip]"],"dataFilePath":"c:\\Users\\[myname]\\AppData\\Roaming\\Code\\User\\globalStorage\\ms-vscode-remote.remote-ssh\\vscode-ssh-host-[vps-ip]-[id]\\data.json"}
[18:42:52.995] Local server env: {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"c:\\Users\\[myname]\\.vscode\\extensions\\ms-vscode-remote.remote-ssh-0.50.0\\out\\local-server\\askpass.bat","VSCODE_SSH_ASKPASS_NODE":"C:\\Users\\[myname]\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe","VSCODE_SSH_ASKPASS_MAIN":"c:\\Users\\[myname]\\.vscode\\extensions\\ms-vscode-remote.remote-ssh-0.50.0\\out\\askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"\\\\.\\pipe\\vscode-ssh-askpass-[askpass]-sock"}
[18:42:53.021] Spawned 30572
[18:42:53.125] > local-server> Spawned ssh: 12024
[18:42:53.165] stderr> OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
[18:42:53.359] stderr> debug1: Server host key: [the key]
[18:42:53.558] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.558] stderr> operable program or batch file.
[18:42:53.607] stderr> Permission denied, please try again.
[18:42:53.638] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.638] stderr> operable program or batch file.
[18:42:53.686] stderr> Permission denied, please try again.
[18:42:53.716] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.716] stderr> operable program or batch file.
[18:42:53.767] stderr> root#[vps-ip]: Permission denied (publickey,password).
[18:42:53.771] > local-server> ssh child died, shutting down
[18:42:53.779] Local server exit: 0
[18:42:53.780] Received install output: OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
debug1: Server host key: [key]
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
Permission denied, please try again.
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
Permission denied, please try again.
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
root#[vps-ip]: Permission denied (publickey,password).
[18:42:53.781] Resolver error: Permission denied (publickey,password).
[18:42:53.783] ------
EDIT2: So apparently this is a problem only occurring on one of my PCs and reinstalling doesn't help
It seems that the remote ssh extension version 0.50.0 broke something related to this. See the issue I opened on the Github:
https://github.com/microsoft/vscode-remote-release/issues/2581
As a workaround, using version 0.49.0 works for me. Do this by right-clicking the extension name and clicking "Install another version...", and select 0.49.0 in the dialogue. Hopefully this gets resolved in a minor version update.
Solved! For most people, the issue is that you did not make the .pem file executable. You need to chmod 400 yourkey.pem for mac, I think 755 for linux, not sure about windows, then move the key into your ssh folder mv yourkey.pem ~/.ssh
Then configure your vscode ssh config file as such.
Host YourHost
HostName ec32-364-207-287-109.compute-1.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/yourkey.pem
I had the same issue with version 0.49+ of Remote SSH on vscode. What I did was cmd-p > Connect To SSH Host > Configure SSH HOSTS and within my config file I noticed I had two entries:
Host <ip>
HostName <name>
User <gungoonsoundcloudwhatsup>
IdentityFile ~/.ssh/file.pub
Host <ip>
HostName <name>
User <gungoonsoundcloudwhatsup>
IdentityFile ~/.ssh/file.pub
So I deleted one and changed the IdentityFile from the .pub file to the appropriate rsa.
That did the trick for me.
Below is the config I used which works for me.
Host vs-ssh.visualstudio.com
HostName vs-ssh.visualstudio.com
User git
IdentityFile file_path
IdentitiesOnly yes
In my case, I had to add User prop to the ssh config because it is using my current device's account name (nemothecollector) while root is correct account name.
Host digital-ocean-vps-as-root
+ User root
HostName 157.245.150.193
IdentityFile ~/.ssh/digital_ocean_vps
IdentitiesOnly yes
Port 22
For me, the issue was the IdentityFile path. On the command line, I simply gave the name of the .pem file. VS Code needs the ~/.ssh/config file to provide the absolute path. Additionally, my key had spaces in it. So I had to wrap the absolute path in quotes, like this: "~/.ssh/key with spaces". Using the $HOME variable didn't work for me. Hope this helps someone.
it might be caused by low time_out in the setting of VSCODE Extension. You can increase that and try again: ctrl + , then find REMOTE SSH under the extension section and increase Connect Timeout to 60 maybe.
Spent an hour on this problem.
I have but one advice.
Double check your username and/or IP address.
This may interest anyone who's been having the issue recently. I'm running the latest VS Code at the time (version 1.74.3 from the 2023-01-09 update).
What I did:
Opened the Command Palette
Selected Remote-SSH: Connect to Host...
Typed in: ssh user#host, and on other attempts: ssh host
After several unsuccessful attempts to log in and still receiving the error posted, I noticed the Command Palette prompt's greyed-out instruction mentioned "... or enter user#host". Considering that this instruction may have been altered from previous versions of VS Code, I changed my command accordingly. I dropped the "ssh" part of the command and this worked: user#host
Vscode insiders stopped to work with remote today morning after (unavoidble) update. It doesn't show remote directory, saying
Connection error: Unauthorized client refused.
and
Failed to connect to the remote extension host server (Error:
Connection error: Unauthorized client refused.)
Deletion of all remote vscode files and killing vscode processes didn't help.
The following transcript can be seen in Output tab:
remote-ssh#0.44.0
linux x64
SSH Resolver called for "ssh-remote+myserver", attempt 1
SSH Resolver called for host: myserver
Setting up SSH remote "myserver"
Using commit id "MYHASH" and quality "insider" for server
Testing ssh with ssh -V
ssh exited with code: 0
Got stderr from ssh: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
Install and start server if needed
> Found existing installation at /home/dimskraft/.vscode-server-insiders/bin/MYHASH...
> Found running server...
>
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
>
> Checking server status with wget
> ==MY-GUID==
"install" terminal command done
Received install output: ==MY-GUID==
Server is listening on port 35693
Spawning tunnel with: "ssh" -L 127.0.0.1:35693:127.0.0.1:35693 -o ConnectTimeout=15 "myserver" bash << 'EOSSH'
echo -e 'Connected to SSH Host - Please do not close this terminal' && sleep infinity
EOSSH
> Connected to SSH Host - Please do not close this terminal
Spawned SSH tunnel between local port 35693 and remote port 35693
Waiting for ssh tunnel to be ready
Tunneling remote port 35693 to local port 35693
Resolved "ssh-remote+myserver" to "127.0.0.1:35693"
------
Downgrading to 1.36.0-insider helped
i keep on running unto this problem after setting up a key pair with eb ssh --setup numerous times. How can I connect to ssh? I am using windows git.
$ eb ssh name-env
The authenticity of host '54.210.133.152 (54.210.133.152)' can't be established.
ECDSA key fingerprint is SHA256:JxdKl8dJXMsfF1EkPRBnOH4hT7Zw6PtfRuRJ7xNu0ao.
Are you sure you want to continue connecting (yes/no)?
Host key verification failed.
INFO: Attempting to open port 22.
INFO: SSH port 22 open.
INFO: Running ssh -i C:\Users\dav\.ssh\aws-eb ec2-user#54.210.133.142
ERROR: An error occurred while running: ssh.
Assuming your public keys are already associated with your EC2 instance, you will also need to make sure your private key has the proper permissions (mode) of 600.
Note: In a *nix environment you would run a chmod 600 /path/to/.ssh/private-key-file but I'm not sure how that translates to file permissions in a Windows environment.