CLion with WSL2, unable to establish a connection (but it was working yesterday).

Completed

I've been using CLion on WSL2 toolchain for a while now and suddenly it stopped working. I have no idea what has changed but it no longer establishes a connection. 

 

Yesterday I was able to use: username@localhost:22 with my password to connect to WSL from clion. Today the same settings give a `cannot establish connection` error. I've tried `sudo service restart` and it does nothing. When I open Ubuntu18.04 shell in windows (the one I've been using), these commands all work:

But the corresponding credentials in CLion still result in the `unable to establish connection error`

 

Looking at the top few lines of my sshd_Config file gives me this (though note I've been playing a bit with the port number. 

```

(base) ciaran@DESKTOP-K0APGUV:~$ head -n40 /etc/ssh/sshd_config
# $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 2222
#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

```    

1
3 comments

Hello!

Could you please try to connect to WSL using putty

Please check this thread - https://youtrack.jetbrains.com/issue/CPP-17763#focus=streamItem-27-3749771.0-0. 

0
Avatar
Permanently deleted user

Hi Anna, 

Thanks for pointing me to the thread, it solved my problem. However, I think there is something more going on here: 

On Wednesday when I wrote asked this question, I woke up, started work and couldn't connect. I was running somebody elses scripts on WSL the previous night so thought they had inadvertantly changed something. I was stuck for 3h not being able to connect to local host, then I tried again (using ciaran@27.0.0.1:22) and suddenly it worked. It worked for a few days then the same thing happened again... aka both putty and CLion would not connect to ciaran@127.0.0.1. I don't know what is going on here but I looked up the WSL IP address with ifconfig and used the `inet` address and I was able to connet using both putty and CLion. 

Hope this helps in pointing the developers to the source of the issue, if indeed there is one. Thanks for the help, best, 

Ciaran 

0
Avatar
Permanently deleted user

I have this problem time and time again. It seems that sometimes clion (or ubuntu) detects a "man in the middle attack" and changes something internal. When this happens, I am unable to conncect to WSL again (whether inside clion or otherwise) until I've done: 

    'sudo service ssh --full-restart'

Which seems to fix the problem. 

0

Please sign in to leave a comment.