VSコードリモートサーバファイルの編集


VSコードリモートサーバファイルの編集
拡張Remote Developmentを使用して、リモート・サーバに接続します.
Remote Developmentは、VSコードの公式プラグインで、リモートフォルダに接続します.This Remote Development extension pack includes three extensions:
Remote - SSH - Work with source code in any location by opening folders on a remote machine/VM using SSH. Supports x86_64 and ARMv7l (AArch32) glibc-based Linux hosts. VS Code Insiders also supports ARMv8l (AArch64) glibc-based Linux hosts. Remote - Containers - Work with a sandboxed toolchain or container based application by opening any folder mounted into or inside a container. Remote - WSL - Get a Linux-powered development experience from the comfort of Windows by opening any folder in the Windows Subsystem for Linux.
プラグインのインストール
直接VSコードカードで検索Remote Developmentそのままインストールすればいいです.
リモートフォルダの接続
まずサーバ上でSSHサービスを開始する必要があります
コンフィギュレーション
  • VSコード設定に追加"remote.SSH.showLoginTerminal": true
  • VSコード左下隅に似ている><>^<><のボタンをクリックして選択Remote-SSH:Connect to Host...プロンプトに従って配置すればいいので、その間にlinuxアカウントのパスワードを入力するように指示して入力すればいい.

  • 問題
    エラーが発生しましたDownloading VS Code Server failed.Please try again later.
    Running remote connection script
    Installing to /home/xxx/.vscode-server/bin/2213894ea0415ee8c85c5eea0d0ff81ecc191529...
    Downloading with wget
    .... 
    "install" terminal command done
    Received install output: b7a67c2b-5d04-47c6-8be8-999adf02ef0c##25##
    Server download failed
    Downloading VS Code Server failed. Please try again later.
    ------
    

    ソリューション:ファイルを手動でサーバにダウンロードし、置き換えます.
    cd ~/.vscode-server/bin/*/
    wget https://update.code.visualstudio.com/commit:2213894ea0415ee8c85c5eea0d0ff81ecc191529
    #commit:                       
    tar -zxvf vscode-server-linux-x64.tar.gz -C ./
    mv vscode-server-linux-x64/* .
    touch 0
    #          
    

    ずっとパスワードを入力したくない
    Linuxサーバの信頼にローカルSSH公開鍵を追加するソリューション
  • ローカルに入るC://Users/YourName/.ssh/フォルダ
  • 存在するか確認id_rsa/存在しない場合ssh-keygen生成
  • id_rsa/id_rsa.pubサーバにコピーした~/.ssh/この公開鍵ファイルに新しい名前を付けることができる
  • /etc/ssh/sshd_configの中のPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2のコメントで、コピーしたばかりのファイルの名前を.ssh/authorized_keysの後に付けます.
  • 試してみることができるssh name@server_ipサーバーをローカルに接続し、パスワードの入力を促すメッセージがなければ修正に成功した.