vscode 技巧总结

SSH远程登录

简介

在这里插入图片描述

密钥对生成

在win10系统,使用已有的ssh,进行命令行生成:

ssh-keygen -t rsa -b 4096

生成的目录,默认会放在用户的.ssh(.表示隐藏的意思,类似Linux)。

C:\Users\XXX(username).ssh

注意,如果之前用vscode做过ssh链接,该目录下会有 know_hosts文件,我理解相当于ssh的指纹缓存,先都删掉,否则后面会有冲突。

Enter passphrase (empty for no passphrase):

这里直接回车,如果填了密码,后面vs链接还要再输入对应密码。

私钥

自己保存在本地,文件名为:id_rsa

公钥

公钥文件名:id_rsa.pub, 拷贝你要链接的远程linux系统中。
保存位置: 如果.ssh没有就创建一个,因为默认配置文件路径就是这样的。

 cp id_rsa.pub  ~/.ssh/authorized_keys

并修改下目录权限,如只root,就600

chmod 600  ~/.ssh/authorized_keys

文件权限,如只root登录,就700

chmod 700  ~/.ssh/authorized_keys

同时配置下ssh配置文件:

sudo vim /etc/ssh/sshd_config

找到下面两项:

PermitRootLogin yes   # 这个不写,没法用root登录,会提示 Permission denied, please try again.
PubkeyAuthentication yes
AuthorizedKeysFile  .ssh/authorized_keys

PasswordAuthentication no 或者直接注释掉

重启ssh

sudo service sshd restart

顺便: 开启启动ssh: systemctl enable ssh

本地 VScode配置

在ssh插件中添加使用身份文件一行就可以了

IdentityFile "C:\Users\xxx\.ssh\id_rsa"  (xxx根据当前路径来)

F1 输入 Remote-SSH:Open configure file
选择 :user

在这里插入图片描述
在这里插入图片描述

vscode 与 WSL配合

安装 插件
在这里插入图片描述
安装好插件后,直接在对应的WSL里面输入 code 就可以在vscode弹出新的窗口了。
在这里插入图片描述

微软为我们提供了一个默认的变量可以直接指向WSL的目录,wsl$ 你可以在运行(win+R)或资源管理器的路径里直接输入\\wsl$进入Ubuntu的目录

在这里插入图片描述
知道地址了,就可以映射到驱动器了,右键网络,选择映射驱动器,把地址放上去就可以了。
在这里插入图片描述

Windows terminal字体:

下载字体
在这里插入图片描述
安装到系统内。

在VSCODE配置项

editor.fontFamily

中添加

'Cascadia Code'

例如我的配置就是

"editor.fontFamily": "'Cascadia Code',Consolas, 'Courier New', monospace",

将配置项

editor.fontLigatures

改为

true

例如我的配置就是

"editor.fontLigatures": true

在这里插入图片描述


新增配置总结:

{
    "launch": {
    

        "configurations": [],
        "compounds": []
    },
    "workbench.colorTheme": "Panda Syntax",
    "editor.fontLigatures": null,
    "editor.fontSize": 22,
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "terminal.integrated.fontSize": 18,
    "terminal.integrated.lineHeight": 1.6,
    "terminal.integrated.letterSpacing": 0.1,
   
    "terminal.integrated.cursorBlinking": true,
    "terminal.integrated.fontFamily": "Lucida Console", //字体设置
    "terminal.integrated.shell.linux": "/bin/zsh",
    "terminal.integrated.drawBoldTextInBrightColors": true,

    "emmet.triggerExpansionOnTab": true,
    "emmet.showAbbreviationSuggestions": true,
    "emmet.showExpandedAbbreviation": "always",
    "window.zoomLevel": 1,
    "editor.wordWrap": "on",
    "editor.detectIndentation": false,
    // 重新设定tabsize
    "editor.tabSize": 2,
    //失去焦点后自动保存
    "files.autoSave": "onFocusChange",
    // #值设置为true时,每次保存的时候自动格式化;
    "editor.formatOnSave": false,
     //每120行就显示一条线
    "editor.rulers": [
    ],
    // 在使用搜索功能时,将这些文件夹/文件排除在外
    "search.exclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/target": true,
        "**/logs": true,
    }, 
    // 这些文件将不会显示在工作空间中
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/*.js": {
            "when": "$(basename).ts" //ts编译后生成的js文件将不会显示在工作空中
        },
        "**/node_modules": true
    },
    "remote.SSH.remotePlatform": {
      "Parrot": "linux"
    },
    "workbench.iconTheme": "vscode-icons",
    "editor.renderControlCharacters": true,
    "terminal.integrated.cursorStyle": "line",
    "terminal.integrated.copyOnSelection": true,
    "terminal.integrated.cursorWidth": 2,
    

}

解决 VSCODE :Pwntools gdb窗口问题

 [ERROR] Could not find terminal binary 'vscode'. Set context.terminal to your terminal.

原来的代码是直接attach调用:

p = process('./dice_game')
gdb.attach(p)
  • 现在修改为:
p = process('./dice_game')

context.terminal = ['tmux','splitw','-h']
gdb.attach(proc.pidof(p)[0],gdbscript="b main")
  • 运行脚本的时候,先配置tmux:
  • tmux set mouse on (设定鼠标滚动支持)
  • 再执行 tmux
    在这里插入图片描述

再输入python exploit.py,[^记得务必在tmux下执行脚本] ,然后就可以发现使用gdb进行debug了,整个命令行界面分为一左一右两部分。

在这里插入图片描述

插件

vscode-icons

在这里插入图片描述
F1 激活配置
在这里插入图片描述

问题

问题1

在这里插入图片描述
解决方法:

  • 检查Settings.json 配置,是否加了对端 remote平台信息:
{
"remote.SSH.remotePlatform":{  //remote system 1: Parrot OS
"Parrot": "linux",
},          //   注意用逗号隔开

"remote.SSH.remotePlatform":{ // remote system 2 : Ubuntu OS
"Ubuntu": "linux",
},
"terminal.integrated.shell.linux": "/bin/zsh",
"editor.fontSize": 18,
"editor.accessibilityPageSize": 18,
"window.zoomLevel": 1,
//"terminal.external.windowsExec": "D:\\1software\\2cmder\\Cmder.exe",
"terminal.external.windowsExec": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.fontSize": 18,
"remote.SSH.defaultForwardedPorts": [
],
"extensions.ignoreRecommendations": false,
"files.associations": {

},
"code-runner.runInTerminal": true,
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"[c]":{
    "files.encoding": "gbk", 
       
       "editor.quickSuggestions":true,
       
   },
   "[cpp]": {
       "editor.wordBasedSuggestions": true,
       
},
"code-runner.ignoreSelection": true,
}

注意,每有一个系统,都要加,保留最后的逗号 ,
“remote.SSH.remotePlatform”:{
“Ubuntu”: “linux”, (系统名【自定义】:系统类型)
},

-排查下 IP地址对不?
虚拟机情况,可能会存在切换链接模式后,重新分配IP地址情况,此时就要排查修改原配置,找到 SSH插件旁边的齿轮,修改新地址:

在这里插入图片描述
在这里插入图片描述

  • 最后删除 know_hosts原缓存内容。
    路径:
C:\Users\xxx\.ssh\known_hosts

在这里插入图片描述

问题2

如果登录,仍然需要密码,大概率可能找不到私钥

ssh -v root@远程服务器IP  

验证ssh登录远程。

查看私钥路径是否正确。

问题3

不能创建 .vscode

Windows中不能创建以"."开头文件。

解决办法:

在项目根目录下面创建vscode目录;
在项目根目录下面按住Shift键并邮件然后选择“在此处打开命令窗口”
执行命令 ren vscode .vscode

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在VSCode中使用Git,你可以通过快捷键"Ctrl + Shift + P"打开VSCode的命令框,然后输入"git"关键字来查看所有VSCode支持的Git命令。如果你想克隆一个Git代码库,你可以使用"Ctrl + Shift + P"打开命令框,然后输入"git clone"并回车,然后在文本框中输入Git代码库的地址。 此外,还有一些关于Git的使用技巧。如果你使用https://开头的地址克隆代码库,在执行git pull或git push操作时会提示你输入账号和密码,这可能会很麻烦。你可以通过配置Git的凭据存储来解决这个问题,具体步骤如下:首先,打开终端或命令行窗口,然后输入以下命令,将Git的凭据存储方式更改为缓存模式: ```shell git config --global credential.helper cache ``` 这样,当你第一次输入账号和密码后,Git会将凭据缓存在内存中一段时间,以便后续的操作不需要再次输入。你可以通过修改`--global`参数为`--timeout=3600`来设置缓存的时间,单位是秒。 另外,如果你使用的是Git的ssh形式克隆代码库,你可以设置SSH密钥来避免频繁输入密码。你可以使用命令`ssh-keygen`生成SSH密钥对,并将公钥添加到Git代码库的设置中。这样,在使用Git操作时,就不需要再输入密码了。 总结来说,VSCode集成了许多Git命令,并通过快捷键和命令框的方式提供了方便的操作方式。另外,通过配置Git的凭据存储和设置SSH密钥,可以避免频繁输入密码,提高使用效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值