I cannot SSH with Kerberos in VS Code on Windows 10 even though PuTTY works fine - visual-studio-code

Problem Summary:
I can SSH to remote host using Kerberos and PuTTY on Windows 10, but I can't connect using VS Code.
Steps I have tried:
I used MIT Kerberos Ticket Manage to generate a Kerberos API key.
Then, in PuTTY I selected both “Attempt GSSAPI authentication” and “Allow GSSAPI credential delegation” . After entering the host name and my username, I can successfully connect to the remote host in PuTTY.
However, I cannot connect to the remote host in VS Code using the following SSH config file:
Host my-host
GSSAPIAuthentication yes
GSSAPIDelegateCredentials yes
User my-name
My error looks like this:
I learned from this Stack Overflow answer that Windows "has two Kerberos libraries (MIT KfW & Windows SSPI)", so my suspicion is that VS Code is not looking for GSSAPI libraries in the correct order, like the PuTTY screen shot. But I don't know how to specify the order like in PuTTY.
Please help! Thanks!

Related

Can't connect to AWS EC2 server via vscode sftp extension on Ubuntu 22.04 OS

I used to connect remote servers provided by Linode and GCP and I use Visual Studio Code via Sftp extension and all works just fine. However, with the same set of configurations, I couldn't connect to my Aws EC2 server.
The following is the sftp.json (with sensitive information changed)
And the aws security setting is as following
The strange thing is that I can ssh connect to the server on the terminal and I can use filezilla to send file with the same credential as well. But somehow I can't connect to it via Visual Studio Code sftp or SSH remote extension.
I searched the anwser on the internet and found an answer that worked for me.
The problem has to do with the Ubuntu 22.04 default server default key setting and not with the VSCode.
The solution is adding
PubkeyAcceptedKeyTypes=+ssh-rsa
in /etc/ssh/sshd_config
and then restart the service on the server with the following command
sudo systemctl restart sshd
The source of the answer comes from https://github.com/liximomo/vscode-sftp/issues/37 under the user windware-ono's answer.

vscode remote ssh connection cannot connect on windows server 2022

I'm trying to setup Remote SSH extension on vscode to connect to a server that runs Windows Server 2022.
First, I can connect with SSH from the terminal ssh username#public_ip -p port then I enter the password and I can access the server.
I installed the Remote - SSH extension on vscode. I was able to connect to a Raspberry Pi without problems... But I cannot connect to a Windows Server 2022.
It asks me to enter the username password twice, then after a few seconds it stops with two errors pop-ups (see picture below).
Could not fetch remote environment
Failed to connect to the remote extension host server (Error: WebSocket close with status code 1006)
errors
Also, from another machine. I can connect to my server with vscode and the same extension (Windows Server 2022) without any problems so I don't think that the server has any issues. Seems like the problem is on my computer that won't connect.
I was able to connect once but I did break something and I don't know what. I tried to reinstall the extension but nothing helped.
EDIT:
I think I fixed it.
Here's what I did.
I uninstalled the Remote - SSH extension
I opened the settings.json on my local computer and deleted everything that had to do with this extension.
Deleted the config file from C:\Users\username\.ssh\config
I restarted vscode
Installed the extension
And it worked.

Visual Studio Code Remote - SSH with key via KeePass / KeeAgent fails

I am having trouble using the remote-ssh plugin in Visual Studio between machine A and machine B where the key is provided by KeeAgent from a KeePass database on machine A.
Machine A runs on Windows 10 and I have set up the Host (machine B) in Visual Studio Code correctly according to the guide. However, when trying to use the remote feature, I get the following error:
[09:48:32.111] Log Level: 2
[09:48:32.121] remote-ssh#0.51.0
[09:48:32.121] win32 x64
[09:48:32.124] SSH Resolver called for "ssh-remote+XXX.XXX.XXX.XXX", attempt 1
[09:48:32.125] SSH Resolver called for host: XXX.XXX.XXX.XXX
[09:48:32.125] Setting up SSH remote "XXX.XXX.XXX.XXX"
[09:48:32.314] Using commit id "91899dcef7b8110878ea59626991a18c8a6a1b3e" and quality "stable" for server
[09:48:32.317] Install and start server if needed
[09:48:38.141] getPlatformForHost was canceled
[09:48:38.142] Resolver error: Connecting was canceled
[09:48:38.147] ------
where XXX.XXX.XXX.XXX obviously is the correct IP of machine B in my output.
As I mentioned, the SSH key for this machine is provided via KeeAgent and works fine with PuTTy. I am not allowed to store a SSH key in plaintext on machine A, hence the Keepass/KeeAgent solution. I guess this is the Problem, that somehow Visual Studio Code does not work with KeeAgent.
Can I work around this, i.e. by telling VS Code to use plink.exe as SSH client, which works with KeeAgent? Or does VS Code allow the encrypted storage of SSH keys itself, thereby making KeeAgent obsolete? I am new to both VS Code and the remote-ssh plugin, so I'm sorry if my questions have obvious solutions.
Maybe the problem lies elsewhere though. In that case I am thankful for every hint.
Thanks!
Go to Options > KeeAgent, then scroll down to Agent Mode Options and activate Enable agent for Windows OpenSSH (experimental): (default: disabled) Enable an SSH agent socket compatible with the built-in Windows 10 SSH client.

How to set ControlMaster with Remote-SSH in Visual Studio Code?

I use Visual-Studio-Code with Remote-SSH extension and I don't want to authentiaction multiple times after I login. So I search the ControlMater option with ssh_config to setup.
After I connected and I got below error message.
Can't connect to Leo-OA: unreachable or not Linux x86_64 (packet_write_poll: Connection to UNKNOWN port -1: Permission denied)
My environment:
Client:
Visual Studio Code 1.35 Stable
Windows 10 1803
Server:
Ubuntu 16.04 LTS
Below is my setting file
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host STONE-OA
HostName 10.32.21.123
User rock
Host Leo-OA
HostName 10.32.21.123
User root
Port 60001
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r#%h-%p
ControlPersist 600
I want to know what is the main problem and how to fix. Thanks everybody.
This feature is not supported on Windows.
Simply running ssh on Windows with ControlMater in PowerShell without VS code has problem too. However you can use ControlMater in WSL without problem.
https://code.visualstudio.com/docs/remote/troubleshooting#_enabling-alternate-ssh-authentication-methods
If you are on macOS and Linux and want to reduce how often you have to enter a password or token, you can enable the ControlMaster feature on your local machine so that OpenSSH runs multiple SSH sessions over a single connection.

Remote Development with NSight 6.5 with "indirect" ssh

Suppose I can log in to a gpu sever named gpu1.sp.sw, and there are gpu2.sp.sw and gpu3.sp.sw to which I cannot log in directly but can be reached by ssh gpu-2, ssh gpu-3, after I am already on gpu1.sp.sw.
My question is: If I want NSight 6.5 to run and debug remotely on gpu-2 or gpu-3, how can I do it?
As workaround you can use ssh tunnels: run something like
ssh gpu1.sp.sw -L2202:gpu2.sp.sw:22 -L2345:gpu2.sp.sw:2345 -nNT
in background console. Then configure NSight remote debugging to connect to server localhost, ssh port 2202 and cuda-gdbserver port 2345.