2020年5月8日金曜日

VS code server failed to start

VS Code ssh remote is not stable,
I have connected to Debian on VirtualBox and after closed the window and shutdone the Debian.
Then Booting up Debian and I Tried to connect from VSCode, I could not successfully establish connection. SSH from terminal is working fine so it is the issue in VSCode.  

solution
running the  folowing command from VS Code from host.  (to open comand plate "ctr + shift + p" .)
Uninstall VS Code Server
and trying to connect from VSCode. I can connect and see folders/Directories on the Debian

2020年5月6日水曜日

VS Code remote SSH to Debian on VirtualBox

Short note how to setup SSH Remote connect VS Code from Windows 10 to Debian vm as user1 on VirtualBox.
Assuming Debian is already running on VM and the user name is "user1" and the ip address is 192.168.122.1.  SSH port was portforward to 3022. 

1.  install OpenSSH for windows server
open power shell terminal on Windows and run following commands
 
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

# This should return the following output:

Name  : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

# Both of these should return the following output:

Path          :
Online        : True
RestartNeeded : False
 
  

2.  SSH KeyGen
create ssh key pair in windows local to set up ssh public key authenticate

$ssh-keygen -t rsa -b 4096

$cd .ssh

#make sure ~/.ssh directry is existing in the user home of Debian. 

$ cat id_rsa.pub | ssh -p 3022 user1@192.168.122.1  'cat >>.ssh/authorized_keys'

3.  Install VSCode SSH remote extension
The Remote - SSH extension

4.  Install VSCode SSH remote extension 

5.  Edit/Create the SSH config file
Edit .ssh/config file on your Windows. .ssh folder is located on C:User/username/.ssh   

Host 192.168.122.1
    HostName 192.168.122.1
    User user1
    Port 3022
now everything is done.
click the ssh connection button on the left bottom of VSCode and follow the prompt.