ã2019å¹´6æ6æ¥ã«ãVisual Studio Codeï¼VS Codeï¼ã®May 2019 (version 1.35)ãå®å®çãããªãªã¼ã¹ããããªã¢ã¼ãéçºï¼ãã¬ãã¥ã¼çï¼æ¡å¼µãå©ç¨ã§ããããã«ãªãã¾ãããããã¯ã©ãããæ©è½ãã¨ããã¨ããµã¼ãã¼ä¸ã®ãã¡ã¤ã«ãããããããã¼ã«ã«ã«ãããã¡ã¤ã«ã®ããã«ç·¨éã§ããæ©è½ã§ãã
ãå©ç¨ã±ã¼ã¹ãæãããªããä¾ãã°ãæ©æ¢°å¦ç¿ã§GPUä»ãã®Ubuntuãµã¼ãã¼ãã¯ã©ã¦ãç°å¢ãå©ç¨ããããã§ããã®éçºã»å®è£ ã¯ãæ®æ®µä½¿ãã®Windowsä¸ã®VS Codeã§è¡ããããã¨ãã£ãå ´åã«ä¾¿å©ã§ããæ©æ¢°å¦ç¿ã§ã¯Jupyter Notebookã§ãããªã¢ã¼ãä¸ã®ãã¡ã¤ã«ã®ç·¨éã¯ã§ããã®ã§éçºã«ã¯å°ããªãã®ã§ãããVS Codeã使ã£ã¦ã³ã¼ããæ¸ãããã¨ããå ´åã«ããã®æ©è½ãå½¹ç«ã¡ããã§ãã
ããããèªèº«ã¯ãJetBotã®ã³ã¼ãã¨ããVS Codeã§è§¦ããããããªãã¨æã£ã¦è©¦ããã®ã§ãããJetBotã®åºç¤ã§ããJetson Nanoã®ãLinux aarch64ãã«ã¯ããã®ãªã¢ã¼ãéçºæ©è½ã対å¿ãã¦ããªãã£ãã§ãï¼åèï¼Remote SSH: Support Linux aarch64 · Issue #60 · microsoft/vscode-remote-releaseï¼ãæ®å¿µ...ã
ãã¨ãããããUbuntu 18.04ã®ã³ã³ãã¥ã¼ã¿ã¼ã«ãªã¢ã¼ãæ¥ç¶ãã¦ã¿ã¾ãããã¾ã ãä¸ã®ä¸ã«ããæé ã®æ å ±ãªã©ãæ´ç·´ããã¦ããªããããªã®ã§ãããããå®è¡ããæé ã¨æ³¨æãã¤ã³ããããã®ããã°ã¨ã³ããªã§ã¯ç´¹ä»ãã¾ããæ¥ç¶ã«ã¯SSHã使ãã®ã§ããªã¢ã¼ãå´ã«SSHãµã¼ãã¼ã®ã¤ã³ã¹ãã¼ã«ãå¿ è¦ã§ãï¼ãã®æé ã¯å²æï¼ã
ï¼1ï¼Remote Developmentæ¡å¼µãã¤ã³ã¹ãã¼ã«
ãã¾ãã¯ãä½æ¥ããããã¼ã«ã«ç°å¢ï¼çè ã®å ´åã¯Windowsï¼ä¸ã®VS Codeã«ãRemote Developmentæ¡å¼µãã¤ã³ã¹ãã¼ã«ãã¾ãã
ãä¸è¨ãªã³ã¯å ããããããã¯æ¬¡ã®ããã«VS Codeä¸ããã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
ãã¤ã³ã¹ãã¼ã«ãå®äºããããSSHæ¥ç¶å ã®ãã¹ããæ§æãã¡ã¤ã«ã§æå®ãã¾ãã
ï¼2ï¼SSHæ§æãã¡ã¤ã«ã§æ¥ç¶å ãã¹ãã®æå®
ãWindowsã§ããã°ï¼»F1ï¼½ãã¼ãæ¼ãããå·¦ä¸ã®ï¼»ç®¡çï¼½ï¼æ¯è»ï¼ã¿ãï¼ï¼»ã³ãã³ã ãã¬ããï¼½ãããã³ãã³ããã¬ãããåºãã¦ããremote-sshããªã©ã¨å ¥åããªã¹ãã«åºãï¼»Remote-SSH: connect to Host...ï¼½ãï¼»Cofigure SSH Hosts...ï¼½ãï¼»~/.ssh/configï¼½ã®é ã«ã¯ãªãã¯ãã¦ããã¾ãï¼â»ã~/.ssh/configã以å¤ã«SSHæ§æãã¡ã¤ã«ãç½®ããã¨ãã§ãã¾ãããããã§ã¯å ¸åçãªå ´åã¨ãã¦èª¬æï¼ã
ãããã«ãããSSHæ§æãã¡ã¤ã«ãéãããã®ã§ãHost
ï¼ç®¡çç¨ã®ååï¼ãHostName
ï¼ãã¹ãåï¼ãUser
ï¼ã¦ã¼ã¶ã¼åï¼ãIdentityFile
ï¼å
¬ééµèªè¨¼ã§ä½¿ãç§å¯éµã®ãã¡ã¤ã«ï¼ãæå®ãã¾ãã
ãç§ã®å ´åã¯ä»¥ä¸ã®ããã«å ¥åãã¾ããã
Host [email protected] HostName dapc86-ubuntu.d-advantage.com User masa-i IdentityFile ~/.ssh/id_rsa
ãããã§ã¯å ¬ééµã®è¨å®ãæ¸ãã§ããåæã§æé ãæ¸ãã¾ããããããã§ããªãå ´åã®æé ãï¼3ï¼ã§ç¤ºãã¦ããã¾ããã¡ãªã¿ã«ãã¹ã¯ã¼ãèªè¨¼ãå¯è½ã§ããããæ¨å¥¨ã¯å ¬ééµèªè¨¼ã®ããã§ãã
ï¼3ï¼SSHã®å ¬ééµèªè¨¼ã«ã¤ãã¦
SSHã¯ã©ã¤ã¢ã³ãã®ã¤ã³ã¹ãã¼ã«
ãã¾ãã¯ãã¼ã«ã«OSã«ãSSHã¯ã©ã¤ã¢ã³ããã¤ã³ã¹ãã¼ã«ãã¾ããPuTTY for Windowsã使ããã¨ããããµãã¼ãããã¦ããªãã£ãã§ããWindows 10ã§ããã°Windows OpenSSH Clientãä¸è¨ãªã³ã¯å ãåèã«ã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
ãOpenSSHã®ã¤ã³ã¹ãã¼ã«ç¶æ³ã確èªãããããWindows 10ã®ï¼»ã¹ã¿ã¼ãï¼½ã¡ãã¥ã¼ãå³ã¯ãªãã¯ãã¦ãï¼»ã¢ããªã¨æ©è½ï¼½ï¼ï¼»ãªãã·ã§ã³æ©è½ã®ç®¡çï¼½ãéããã¨ãããèªåã®å ´åã¯ã¤ã³ã¹ãã¼ã«æ¸ã¿ã§ããã
ãSSHã¯ã©ã¤ã¢ã³ããã¤ã³ã¹ãã¼ã«ã§ããããå ¬ééµï¼id_rsa.pubï¼ï¼ç§å¯éµï¼id_rsaï¼ãçæãã¾ãã
SSHã®å ¬ééµï¼id_rsa.pubï¼ï¼ç§å¯éµï¼id_rsaï¼ã®çæ
ãPowerShellï¼ç®¡çè ã¢ã¼ãï¼ã使ã£ã¦çæããæé ãç´¹ä»ãã¾ãã
ãã¾ãã¯ï¼»ã¹ã¿ã¼ãï¼½ã¡ãã¥ã¼ãå³ã¯ãªãã¯ã¡ãã¥ã¼ããï¼»Windows PowerShellï¼ç®¡çè ï¼ï¼½ãå®è¡ãã¾ãï¼â»è¨å®ã«ãã£ã¦ã¯ãããï¼»ã³ãã³ã ããã³ããï¼½ã«ãªã£ã¦ãã¾ãããPowerShellãä½ã¨ããã¦éãã¦ãã ãã...ï¼ã
ããã¨ã¯ãé çªã«ã³ãã³ããæã¡è¾¼ãã§ããã¾ãã次ã®ç»åã®ããã«ãªãã¾ããããã®ä¸ã«ãããããæã£ãå 容ãåèã¾ã§ã«è¼ãã¦ããã¾ãã
ããã£ã¬ã¯ããªã移åã
PS C:\WINDOWS\system32> cd ~\.ssh
ãSSHã®éµãçæãéµãä¿åãããã¡ã¤ã«ã¯ããã©ã«ãã®ã~/.ssh/id_rsaãã®ã¾ã¾ã§ãä¸æ¸ãï¼Overwriteï¼ã¨åºãå ´åã¯ãã§ã«ããã®ã§ã注æãã¦ãã ããï¼â»ä¸æ¸ãããã¨ä»ã«å½±é¿ãåºã¾ãï¼ããã¹ãã¬ã¼ãºï¼passphraseï¼ã¯ç©ºã«ããã«ä½ãå ¥åããæ¹ãããã§ãã
ssh-keygen -t rsa -b 4096
ãéµãã§ããããå ¬ééµï¼id_rsa.pubï¼ããªã¢ã¼ãæ¥ç¶å ã«ã¢ãããã¼ããã¾ãã
ãªã¢ã¼ãã³ã³ãã¥ã¼ã¿ã¼ã¸ã®SSHå ¬ééµï¼id_rsa.pubï¼ã®ã¢ãããã¼ã
ããã®ä½æ¥ãå¼ãç¶ããPowerShellï¼ç®¡çè ã¢ã¼ãï¼ã使ãã¾ããã
ãä¸è¨ã®ã¨ããã«éµãçæããå ´åã¯ã以ä¸ã®ã³ãã³ããé çªã«æã¡è¾¼ãã§ããã¾ãã
ã以ä¸ã®ã³ãã³ãã¯ã以éã§ä½¿ããã¹ãªã©ã®æååãä½ã£ã¦ããã ãã§ãã[email protected]
ã¯ãï¼ã¦ã¼ã¶ã¼åï¼ï¼ ï¼ãã¹ãåï¼ã§åèªã®ãã®ãå
¥åãã¦ãã ããã
$UserAtRemoteHost = "[email protected]"
$LocalSourcePublicKey = $env:UserProfile + "\.ssh\id_rsa.pub"
$RemoteTargetPublicKey = $UserAtRemoteHost + ":~/tmp.pub"
ãä¸è¨ã®ã³ãã³ãã§ãå ¬ééµãã¢ãããã¼ããã¦ãã¾ããéä¸ã§ãªã¢ã¼ãã³ã³ãã¥ã¼ã¿ã¼ã«ãã°ã¤ã³ããããã®ãã¹ã¯ã¼ããèãããã®ã§ãåèªã®ãã®ãå ¥åãã¦ãã ããã
scp $LocalSourcePublicKey $RemoteTargetPublicKey
ã次ã®ã³ãã³ãã¯ããªã¢ã¼ãã³ã³ãã¥ã¼ã¿ã¼ä¸ã§ãã¢ãããã¼ãããå ¬ééµãæå¹ã«ãã¦ãã¾ãã
ssh $UserAtRemoteHost "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub"
ã以ä¸ã®æé ã§ãããããæã£ãå 容ãåèã¾ã§ã«è¼ãã¦ããã¾ãã
ã念ã®ãããå®éã«æ¥ç¶ã§ããããã«ãªã£ãããã次ã®ã³ãã³ãã§ãã§ãã¯ãã¦ã¿ã¦ãã ããï¼â»[email protected]
ã¯ãï¼ã¦ã¼ã¶ã¼åï¼ï¼ ï¼ãã¹ãåï¼ã§åèªã®ãã®ãï¼ããã°ã¤ã³ã§ããããexit
ãªã©ã¨æã£ã¦ãã°ã¢ã¦ããããå®äºã§ãã
ssh -i ~/.ssh/id_rsa [email protected]
ã以ä¸ã§æºåã¯çµããã®ã¯ããªãã§ããã©ãä½åº¦ããã£ã¦ã¿ã¦ãããã°ã¤ã³ã¿ã¼ããã«ã®è¡¨ç¤ºããè¨å®ããæ¹ããã©ãã«ãå°ãªãã£ãã®ã§ãï¼4ï¼ã説æãã¦ããã¾ãã
ï¼4ï¼ããã°ã¤ã³ã¿ã¼ããã«ã®è¡¨ç¤ºãã®è¨å®
ãã¡ãã¥ã¼ãã¼ã®ï¼»ãã¡ã¤ã«ï¼½ï¼ï¼»åºæ¬è¨å®ï¼½ï¼ï¼»è¨å®ï¼½ããï¼»è¨å®ï¼½ãã¼ã¸ãéããï¼»è¨å®ã®æ¤ç´¢ï¼½æ¬ã«ãremote sshãã¨å ¥åãå·¦å´ã®ããªã¼ããï¼»æ¡å¼µæ©è½ï¼½ï¼ï¼»Remote - SSHï¼½ãé¸æãã¦ãå³å´ã®è¨å®å 容ã«ããï¼»Remote.SSH: Show Login Terminalï¼½ã«ãã§ãã¯ãå ¥ãã¦ãã ããã
ãããã§æºåä¸ç«¯ã§ããå®éã«ããªã¢ã¼ããã¡ã¤ã«ãéãã¦ã¿ã¾ãããã
ï¼5ï¼Visual Studio Codeã«ãããªã¢ã¼ãéçº
ãï¼2ï¼ã¨åãæé ã§ã³ãã³ããã¬ãããéããï¼»Remote-SSH: connect to Host...ï¼½ãã¯ãªãã¯ãã¾ããä»åº¦ã¯ãï¼2ï¼ã®SSHæ§æãã¡ã¤ã«ã§è¨å®ããHost管çåï¼ãã®è¨äºã®å ´åã¯ã [email protected]ãï¼ã表示ããã¾ãã®ã§ããããã¯ãªãã¯ãã¦ãã ããã
ãããã¨éä¸ã§ãï¼»ã¿ã¼ããã«ï¼½ã¦ã£ã³ãã¦ãç«ã¡ä¸ããï¼â»ï¼4ï¼ã®è¨å®ãããªãã¨ç«ã¡ä¸ãããªãï¼ãéµã®ãã¹ãã¬ã¼ãºã®å ¥åãæ±ãããã¾ãã®ã§ãåèªã®ãã®ãå ¥åãã¦ãã ããããã¹ãã¬ã¼ãºãèãããã®ãããä¸åãã¨æããããä½åº¦ãèããã¾ãï¼ä»å¾ãæ¹åãã¦ãããã¨ä¿¡ãã¦ãã¾ã...ï¼ã
ãæ¥ç¶ã«æåããã¨ãå¥ã¦ã£ã³ãã¦ã§VS Codeãããä¸ã¤ç«ã¡ä¸ãããï¼»ãã©ã«ãã¼ãéãï¼½ãã¿ã³ãããªã¢ã¼ãã³ã³ãã¥ã¼ã¿ã¼ä¸ãç°¡åã«æ¢ç´¢ã§ãã¾ãã
ããã¨ã¯ããªã¢ã¼ãã³ã³ãã¥ã¼ã¿ã¼ä¸ã®ãã©ã«ãã¼å ã®ãã¡ã¤ã«ãããããããã¼ã«ã«ãã¡ã¤ã«ã®ããã«ç·¨éã§ãã¾ãã
ãã¡ãªã¿ã«ããã®ç¶æ ã§æ¡å¼µæ©è½ãã¤ã³ã¹ãã¼ã«ãããã¨ããã¨ãå½ç¶ãªããããã¼ã«ã«ç°å¢ã§ã¯ãªããªã¢ã¼ãã³ã³ãã¥ã¼ã¿ã¼ä¸ã«ã¤ã³ã¹ãã¼ã«ããã¾ãã
ã以ä¸ã§ããä¸åº¦ã¤ãªããã°å¿«é©ã§ãã