由于Linux代码调试需要,如果当前开发系统是windows的话,可以选择使用CLion 远程链接 WSL。
所以需要子系统开启ssh

安装 ssh

sudo apt-get install openssh-server

Linux 开启密码登录

sudo vim /etc/ssh/sshd_config

找到passwordAuthentication项,修改成yes
重启ssh服务

sudo service sshd restart

查看服务状态

service ssh status
# * sshd is running  显示此内容则表示启动正常

如果提示 sshd error: could not load host key 则需要重新生成 key

dpkg-reconfigure openssh-server

如需密码设置

sudo passwd user-name

如果启动sshd时,报“Could not load host key”

Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key

查看下文件是否存在

ll /etc/ssh/

解决方法,重新生成密钥文件

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key

Clion中子系统配置请参考《Clion Windows Linux子系统

如果启动报 ssh:unrecognized service

sudo /etc/init.d/ssh restart
sudo /etc/init.d/ssh start

ubuntu 安装 gdb

sudo apt update
sudo apt install gdb

参考

https://www.jetbrains.com/help/clion/quick-tutorial-on-configuring-clion-on-windows.html#WSL
https://www.cnblogs.com/netonline/p/7410586.html
https://blog.csdn.net/zhouzme/article/details/81087837
http://www.gdbtutorial.com/tutorial/how-install-gdb