Vscode配置Remote遠(yuǎn)程開發(fā)環(huán)境

[TOC]

1. Vscode配置Remote遠(yuǎn)程開發(fā)環(huán)境

分為服務(wù)器可以連網(wǎng)和不能連網(wǎng)的兩種情況。首先服務(wù)器有網(wǎng)插件基本都可以裝,就很方便了。這里重點(diǎn)說(shuō)一上斷網(wǎng)的情況下要如何安裝。

大體步驟如下:

  1. 安裝最新的vscode和vscode插件
  2. 配置遠(yuǎn)程服務(wù)器可以遠(yuǎn)程免密登錄
  3. 配置Remote-ssh連接遠(yuǎn)程服務(wù)器
  4. 配合Remote-ssh使用,更新git版本到最新版本

1.1. 離線安裝vscode最新版本和插件

參考鏈接:https://mp.weixin.qq.com/s/n7zyDFOeHd9K5oSKz7Zg9Q

官網(wǎng)下載VSCODE鏈接: https://code.visualstudio.com/
官網(wǎng)下載插件鏈接: https://marketplace.visualstudio.com/VSCode

下載插件并安裝: Remote-SSH, Remote-SSH Editing Configure File

連接服務(wù)器,先配置免密登錄 直達(dá)鏈接

配置remote-ssh,連接遠(yuǎn)程服務(wù)器

# 先將.vscode-server清理掉,如果只是升級(jí),也可以只清理掉bin下面的內(nèi)容
cd ~
rm -rf .vscode-server

# 使用remote-ssh先登錄服務(wù)器,會(huì)產(chǎn)生一個(gè)目錄,目錄就是匹配vscode版本的id
# /root/.vscode-server/bin/26076a4de974ead31f97692a0d32f90d735645c0
# 如果目錄下已經(jīng)有該文件,直接刪掉之后再重新下載
# 解壓之后沒(méi)有vscode-server-linux-x64這種再一層的目錄,在bin下面操作
# 文件大概是34M,下載可能會(huì)比較慢
wget https://update.code.visualstudio.com/commit:26076a4de974ead31f97692a0d32f90d735645c0/server-linux-x64/stable
tar -zxvf vscode-server-linux-x64.tar.gz
mv vscode-server-linux-x64/* .

再次連接服務(wù)器,這次可以連接了

1.2. 配置免密登錄

在windows10的機(jī)器上生成公鑰:

# 打開.ssh目錄,生成公鑰, id_rsa.pub
cd C:\Users\xxx\.ssh
ssh-keygen

拷貝到 linux 服務(wù)器下,并修改服務(wù)器上的配置

# 沒(méi)有ssh目錄的話,可以手動(dòng)創(chuàng)建
cd ~
cd .ssh/
# 將公鑰信息添加到文件末尾
cat id_rsa.pub >> authorized_keys

# 配置sshd_config參數(shù),把下面兩行數(shù)據(jù)的注釋去掉
cat /etc/ssh/sshd_config | grep -e  PubkeyAuthentication -e AuthorizedKeysFile
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys .ssh/

# 重啟sshd,下面分別是centos6和centos7的重啟命令
service sshd restart
systemctl restart sshd

嘗試連接 linux 服務(wù)器

ssh root@ip -p port

1.3. 更新Centos下的git版本

參考鏈接: https://blog.csdn.net/jj546630576/article/details/83068995

# 安裝依賴
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc gcc perl-ExtUtils-MakeMaker xmlto

# 卸載原本的git版本
yum remove git

# 下載最新的git版本,
wget https://github.com/git/git/archive/v2.2.1.tar.gz

# 編譯git
tar zxvf v2.2.1.tar.gz
cd git-2.2.1
make configure
./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
make all doc
make install install-doc install-html

# 配置到可識(shí)別的環(huán)境
ln -s /usr/local/git/bin/git /usr/bin/git
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc

# 查看更新后的git版本
git --version
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容