在做嵌入式開發(fā)時,很多時候需要遠(yuǎn)程連接或者遠(yuǎn)程調(diào)試設(shè)備,這時可以通過VScode上的插件來很方便的進(jìn)行遠(yuǎn)程連接和調(diào)試。
ssh遠(yuǎn)程連接嵌入式開發(fā)板:
1、安裝vscode ssh遠(yuǎn)程插件:Remote-SSH。
2、點(diǎn)擊"+",輸入ssh連接命令。(eg:ssh root@192.168.1.4)?
3、選擇要更新的ssh配置文件,一般是C:\用戶\用戶名\.ssh\config,根據(jù)實(shí)際情況選擇。添加好主機(jī)后點(diǎn)擊連接。?
?
?4、如果沒有出現(xiàn)上面連接的選項(xiàng),按組合鍵"Ctrl"+"Shift"+"p",輸入Remote-SSH,選擇連接到主機(jī)。然后選擇系統(tǒng)類型,嵌入式設(shè)備的系統(tǒng)一般都是Linux。
?5、輸入密碼(遠(yuǎn)程主機(jī)用戶的密碼)。
6、登入成功后,可以選擇一個文件夾,這樣每次登入都會默認(rèn)進(jìn)入這個目錄下。
ssh免密登入設(shè)置:?
1、在本地(Windows、Ubuntu或者M(jìn)acos)生成一對ssh公私密鑰。以Windows為例,打開?cmd 輸入?ssh-keygen 命令,然后一直按回車就可以了,應(yīng)該和下面輸出差不多。
C:\Users\86199>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\86199/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\86199/.ssh/id_rsa.
Your public key has been saved in C:\Users\86199/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:k/fZW0MI2odocmufHxptziPKxrNu4guuq0fTX/miWEs 鏉庡皬鐧紷DESKTOP-5ONQ0N7
The key's randomart image is:
+---[RSA 2048]----+
| |
| |
| . |
| .+ o . |
| . .S=oo o . |
| o . +=..oo. |
| . ...Eoo..o+...|
| .. =o+*.oB..o.|
| .oooo.=B==+o+o |
+----[SHA256]-----+
2、會在 C:\User\XXX\ 目錄下生成一個.ssh的文件夾(XXX代表你在Windows上面的名字),里面有?id_rsa(私鑰)?和 id_rsa.pub(公鑰) 兩個文件。
其中的 config 就是之前 VSCode 中的配置文件,里面保存著服務(wù)端的IP、名字和用戶。?
3、在遠(yuǎn)程服務(wù)端的用戶目錄下(就是ssh登入的默認(rèn)目錄),創(chuàng)建一個 .ssh 目錄,然后進(jìn)入?.ssh 目錄下創(chuàng)建一個?authorized_keys 文件。?將之前生成的公鑰?id_rsa.pub 文件里的內(nèi)容全部復(fù)制到?authorized_keys 文件中就可以了。
scp開發(fā)板上傳和下載文件:
上傳和下載文件使用的命令都是 scp,無論是 Windows 還是 Linux 只要安裝了 ssh 都能使用。
上傳:scp /path/file user@IP:/path/
下載:scp user@IP:/path/file?/path?
scp /home/root/workspace/samples/bin/key_test biqu@192.168.0.102:/home/biqu/workspace/
The authenticity of host '192.168.0.102 (192.168.0.102)' can't be established.
ED25519 key fingerprint is SHA256:8qDFfC1AfmGhGmH09Vrc1m8S/zwktfRujVx4F9mpKgw.
This host key is known by the following other names/addresses:
~/.ssh/known_hosts:6: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.0.102' (ED25519) to the list of known hosts.
biqu@192.168.0.102's password:
key_test 100% 464KB 2.8MB/s 00:00
按格式輸入命令后,輸入用戶密碼,就將 key_test 文件從本地上傳到遠(yuǎn)程 biqu 用戶的 workspace 目錄下了。如果需要上傳整個目錄就需要加上 -r 參數(shù)。
scp biqu@192.168.0.102:/home//biqu/workspace/key_test /home/root/workspace
/samples/bin
biqu@192.168.0.102's password:
key_test 100% 464KB 1.7MB/s 00:00
?按格式輸入命令后,輸入用戶密碼,就將遠(yuǎn)程 biqu 用戶的 key_test 文件下載到本地 bin?目錄下了。如果需要下載整個目錄就需要加上 -r 參數(shù)。文章來源:http://www.zghlxwxcb.cn/news/detail-813103.html
以上就是VScode遠(yuǎn)程連接嵌入式開發(fā),之后有機(jī)會再把使用gdb調(diào)試補(bǔ)上,如果有什么疑問或建議,歡迎在評論區(qū)中提出嗷~。文章來源地址http://www.zghlxwxcb.cn/news/detail-813103.html
到了這里,關(guān)于VScode遠(yuǎn)程連接開發(fā)嵌入式開發(fā)板的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!