vscode 配合wsl做linux下的開發
vscode 配合wsl做linux下的開發
安裝wsl
直接在商店裡面搜尋wsl
記住在windows功能項裡面勾選 適用於Linux的Windows子系統
配置wsl
安裝完成之後輸入wsl
進入剛剛安裝的wsl
1.更換阿里雲映象
sudo sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
sudo apt update -y
sudo apt upgrade -y
2.安裝ssh服務
這裡剛剛進去我也是被坑了一下 ps -aux | grep ssh什麼都沒有,重啟一下直接報錯
-> # service ssh restart
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
* Restarting OpenBSD Secure Shell server sshd
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
然後重新安裝一下
apt remove openssh-server
apt install openssh-server
這裡需要改一下配置 sudo vim /etc/ssh/sshd_config改下面2個點
13 Port 22
......
55 # To disable tunneled clear text passwords, change to no here!
56 PasswordAuthentication yes
57 #PermitEmptyPasswords no
port改成22, 56行的密碼認證開啟,之前no好像還需要一個認證檔案
vscode連線wsl
然後根據自己的ip就可以連上去了
vscode就直接連上去了,我另外一個用SecureCRT也很方便
安裝c/c++環境,連線到github上面的專案
sudo apt-get install gdb
sudo apt-get install g++
vscode的很神奇,好像直接都配置好了,我進去也是直接的好的配置資訊
然後launch.json好像直接生成
{
"version": "0.2.0",
"configurations": [
{
"name": "g++ - 生成和除錯活動檔案",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "為 gdb 啟用整齊列印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
另外一個tasks.json
{
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Generated task by Debugger"
}
],
"version": "2.0.0"
}
新建一個hello.cpp按下F5按要求好像沒有什麼卡殼的,很順利,我遇到一個生成的可執行hello與hello.cpp不在一個路徑,生成的hello和.vscode一個目錄,老是報錯後來我重啟又好了,奇怪
上傳GitHub
然後就是自己的github倉庫
自己的clone到本地,配置一下自己的資料倉儲資訊
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <klaus@DESKTOP-1J0SU5A.localdomain>) not allowed
然後配置完成之後,輸入自己的賬號密碼完成更新,一句話完成更新
git add -A && git commit -m “refresh” && git push
詳細內容如下:
klaus@DESKTOP-1J0SU5A:~/wintype/Daily-algorithm$ git config --global user.email *****@outlook.com
klaus@DESKTOP-1J0SU5A:~/wintype/Daily-algorithm$ git config --global user.name *******
klaus@DESKTOP-1J0SU5A:~/wintype/Daily-algorithm$ git add -A && git commit -m "refresh" && git push
[master d695eb9] refresh
1 file changed, 9 insertions(+)
create mode 100644 hello/hello1.cpp
Username for 'https://github.com': **********
Password for 'https://***********@github.com': **********
Counting objects: 8, done.
Delta compression using up to 8 threads
github上就完成更新了。
同步的時候出現了一個每次都要輸入賬號和密碼的問題
klaus@DESKTOP-1J0SU5A:~/wintype/Daily-algorithm$ git push origin master
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E********mTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
這裡需要生成一個ssh-key
klaus@DESKTOP-1J0SU5A:~/wintype/Daily-algorithm$ ssh-keygen -t rsa -C "******@outlook.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/****/.ssh/id_rsa): /home/*****/.ssh/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/*****/.ssh/id_rsa.
Your public key has been saved in /home/*****/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:4AXCEcp2UyMCSRNj1UXgysG+*****/NnIJ9oz/RtI ******@outlook.com
The key's randomart image is:
+---[RSA 2048]----+
|oO++B+Bo |
|o.=+oB o |
.....
| . . + |
| o |
| . |
+----[SHA256]-----+
klaus@DESKTOP-1J0SU5A:~/wintype/Daily-algorithm$
klaus@DESKTOP-1J0SU5A:~/wintype/Daily-algorithm$ cat ~/.ssh/id_rsa.pub
然後把生成的金鑰拷貝到github裡面
相關文章
- wsl 下的 docker 開發實踐(上)Docker
- PearProject 在 WSL 下的開發環境部署教程Project開發環境
- Win10 下 Laravel 開發方法一:WSLWin10Laravel
- 【記錄】WSL 下搭建前端開發環境前端開發環境
- 基於 VSCode下的 Flutter 開發VSCodeFlutter
- Win10 下的 WSL (Linux 子系統) 開發環境搭建 (基礎配置)Win10Linux開發環境
- Linux下rz,sz與ssh的配合使用Linux
- Win10 下 Laravel 開發方法二:WSL+DockerWin10LaravelDocker
- linux下使用vscode和makefile搭建C++開發環境LinuxVSCodeC++開發環境
- Mac下用VSCode開發除錯GolangMacVSCode除錯Golang
- Win10 下的 WSL (Linux 子系統) 開發環境搭建 (PHP+Nginx+MySQL+Composer+SSH)Win10Linux開發環境PHPNginxMySql
- # WIN10 系統下 WSL 配置 Laravel 開發環境指南Win10Laravel開發環境
- WSL2:在Windows系統中開發Linux程式的又一神器WindowsLinux
- WSL設定php開發環境PHP開發環境
- ClojureScript/OM 配合 descjop 開發筆記筆記
- VSCode + WSL 2 + Ruby環境搭建詳解VSCode
- WSL2+Terminal+VScode配置除錯VSCode除錯
- Linux下開發-alarmLinux
- Linux下開發-reallocLinux
- Linux下開發CLinux
- 專案中如何配合VScode使用EslintVSCodeEsLint
- UWP開發中Binding配合Converter的使用
- window系統下搭建 wsl2 開發環境(嘗試階段)開發環境
- (WSL) Ubuntu 快速搭建 PHP 開發環境UbuntuPHP開發環境
- Oracle在Linux下的C開發OracleLinux
- Linux下的軟體開發(轉)Linux
- 我為什麼使用Linux做開發Linux
- 十分鐘完成vscode配合Eslint使用VSCodeEsLint
- VSCode 如何遠端連線其他主機的 WSL2VSCode
- vscode 開發Vue配置VSCodeVue
- VS Code + WSL 搭建 RaspberryPi Pico 開發環境開發環境
- Oracle在Linux下的C開發(轉)OracleLinux
- win10 配合 phpstorm 使用 docker 開發Win10PHPORMDocker
- VSCode + Docker 的 PHP 開發環境VSCodeDockerPHP開發環境
- [Windows] Windows 10 開啟 WSL 擁抱Linux系統WindowsLinux
- VSCode遠端連線其他主機的WSL2的問題VSCode
- Linux下開發-IO複用Linux
- VScode 遠端開發配置VSCode