Issue
I'm having some problems connecting to wsl from visual studio 2019 via ssh for c++ development . Windows Version : 10.0.18362 Build 18362 . ubuntu version on wsl : Ubuntu 18.04.4 LTS .
steps I followed to setup an ssh connection :
1- installed the ssh server sudo apt install openssh-server
2- edited the config file at /etc/ssh/sshd_config
. my config is :
# $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
Port 1478
#AddressFamily any
ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
# override default of no subsystems
Subsystem sftp /usr/lib/openssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
3- started the ssh server on wsl sudo service ssh start
4- tested the connection with putty and bitvise ssh and all work very well, I can ssh into ubuntu and have a terminal and sftp session . also I made sure that the server is running via powershell netstat -an
5- went to visual studio Tools -> Options -> Cross Platform -> Connection Manager -> Add
I entered the same host, port, user and password I used in putty and bitvise ssh but I got some delay and nothing happens and no errors are shown, then I click on connect again and get an error at host and port fields saying: Connectivity failure. Please make sure host name and port number are correct . after that all tries result in the same error even if I used wrong user or password
I tried to use wrong user or password at the first try and I got some delay and an error was shown for user and password fields saying that the are incorrect . after I enter the correct credentials I get the first behavior again : delay and nothing happens then host and port errors .
EDIT: I enabled the connection logs and I got :
21:19:14.5149607 [Info, Thread 1] liblinux.RemoteSystemBase: Connecting over SSH to localhost:1478
21:19:15.9131254 [Info, Thread 1] liblinux.IO.RemoteFileSystemImpl: Connecting over SFTP to localhost:1478
21:19:21.7184045 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "echo $0" finished with exit code 0 after 44.0724ms
21:19:21.7234275 [Info, Thread 1] liblinux.TargetShell: Found shell 'bash' in use on '822733995'
21:19:21.8709831 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "cat /etc/os-release" finished with exit code 0 after 143.089ms
21:19:22.0309547 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "uname -m" finished with exit code 0 after 154.5144ms
21:19:22.1872648 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "uname -r" finished with exit code 0 after 150.4997ms
21:19:22.3497282 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "g++ -v" finished with exit code 0 after 119.5743ms
21:19:22.6425693 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "clang++ -v" finished with exit code 0 after 286.7829ms
21:19:22.7933986 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "gdbserver --version" finished with exit code 0 after 143.7903ms
21:19:22.9545787 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "gcc -v" finished with exit code 0 after 154.3292ms
21:19:23.4517720 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "gdb -v" finished with exit code 0 after 489.7793ms
21:19:24.1040235 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "/usr/bin/gdb -v" finished with exit code 0 after 643.8794ms
21:19:24.2484893 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "/usr/local/bin/gdb -v" finished with exit code 127 after 134.6787ms
21:19:24.4071410 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "rsync -v" finished with exit code 1 after 153.1007ms
21:19:25.0386960 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "lldb -v" finished with exit code 0 after 623.3945ms
21:19:25.2065987 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "ninja --version" finished with exit code 0 after 161.349ms
21:19:25.5204182 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "cmake --version" finished with exit code 0 after 305.7367ms
21:19:25.7033145 [Info, Thread 1] liblinux.Shell.CommonCommandBase: Command "make -v" finished with exit code 0 after 173.4825ms
21:19:40.9288082 [Info, Thread 1] liblinux.RemoteSystemBase: Disconnecting over SSH from "localhost:1478"
21:19:40.9441152 [Info, Thread 1] liblinux.IO.RemoteFileSystemImpl: Disconnecting over SFTP from localhost:1478
Solution
I didn't manage to add a connection through visual studio IDE so I used the ConnectionManager.exe tool . at first I got an error because the date was in Arabic but after I changed the date the connection was added successfully .
Answered By - dev65