VScode can't connect remotely, and found that the user file owner and group permissions have changed to other people

Problem: VScode can't connect to the server with the lab 8 card, but other servers can. Both Xshell and Xftp can be used to connect, only VScode can’t connect, which means it’s not an SSH problem.

Analysis: VScode connection reports an error showing that mkdir cannot access the folder, and creating a folder in /home/zhangl also requires sudo permission, which means there is a permission problem. Then, through MobaXterm, it is found that the owner and group permissions of the user /home/zhangl have changed to dengyy (other users).

[It should be that someone accidentally changed my user permissions by mistake, and found that there are problems with the permissions of several users]

Therefore, record the method of changing owner and group permissions .


1. If you need to modify the owner and group permissions of /home, use the following method: (generally not required, you can skip it)

Switch back to the parent directory of /home

cd ..  #切到/home目录的上级目录
sudo chown root:root ./home/  # 只修改当前/home文件夹的权限(不含上下级子文件)

2. If you only need to modify the owner and group permissions of the current user, use the following method:

Note: -R traverses the current folder and its subfolders, .* means all hidden files (including the upper level directory, ie. and ..), because of the reason of ., it will cause the current folder to jump out, even Change the parent folder. Therefore, it can be executed under each user's lower-level folder, so that even the upper-level folder is still in the current user! ! !

cd /home/zhangl/test/   # 切到当前用户的test文件夹里,也可以是其它文件夹
sudo chown -R zhangl:zhangl .*  # 修改当前用户的所有文件的owner和group权限

In this way, you can see that the owner and group of the current user have become zhangl, and then connect to VScode at this time.

Guess you like

Origin blog.csdn.net/weixin_41596697/article/details/128278875