~/.ssh
目录。cd ~/.ssh
cat id_rsa.pub >> authorized_keys
sudo chmod 600 authorized_keys
sudo chmod 700 ~/.ssh
这项操作可以部署多个公钥,命令会在 authorized_keys 后面追加,而 Linux 公钥验证检测 authorized_keys 文件中的公钥,一个公钥只运行一个用户使用登录。
sudo vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
sudo service sshd restart
直接使用Remote - SSH插件连接即可,第一次要输入密码,后面因为有了密钥就不用输入密码了。
如果不行的话可能是生成的公钥id_rsa.pub找不到,(增加)改一下IdentityFile改成公钥路径。
Host 取个名字
HostName 127.0.0.1
User root
IdentityFile "H:\你的公钥路径\id_rsa.pub"
配置launch.json如下,修改"program"参数。
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 附加",
"type": "cppdbg",
"request": "attach",
"program": "/home/...", //这里要程序的绝对路径
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-gdb-set scheduler-locking step",
"ignoreFailures": true
}
]
}
]
}
OUTPUT窗口提示有“No space left on device”,这是因为磁盘不足或者vscode的日志文件太多了,这时候可以清理磁盘文件、手动去服务器上执行:
rm -rf ~/.vscode-server/bin/*
再重试即可。
提示"Bad owner or permissions on .ssh/config",为文件权限错误,将config文件属性->高级->禁用继承->禁用所有继承权限,然后再添加只有本用户有权限。
Permissions 0644 for ‘/root/.ssh/id_rsa’ are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
将id_rsa文件属性->高级->禁用继承->禁用所有继承权限,然后再添加只有本用户有权限。
如果之前有别的vscode进程连过远程机器,需要重启下远程服务器的VScode Server,在VSCode点击左下角设置按钮->命令面板->Remote SSH: Kill VS Code Server on Host。