一、问题描述
按照《VsCode + gdb + gdbserver远程调试C++程序》中介绍的方法,配置好VsCode后,可以查看远程Linux主机上的文件的内容,但是修改文件内容后保存失败,提示:Failed to save XXX:Unable to write file 'vscode-remote://ssh-remoteXXX'(NoPermissions(FileSystemError):Error:EACCES:permission denied):
二、解决方法
首先编辑远程Linux主机上的sshd_config文件:
sudo vim /etc/ssh/sshd_config
注释掉里面的PermitRootLogin without-password这行,即改成#PermitRootLogin without-password
在该文件最下面增加一行:PermitRootLogin yes
然后重启Linux主机上的ssh服务:sudo service ssh restart
进入Windows主机的“C:\Users\你的用户名\.ssh”目录,编辑config文件:
根据需要被远程连接的Linux主机ip,找到对应的“HostName”,将对应的“User”后的用户名改为root:
执行上述操作后,通过VsCode重新远程连接Linux主机,就可以成功修改Linux上的文件了。