<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ssh &#8211; richliu&#039;s blog</title>
	<atom:link href="https://blog.richliu.com/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Wed, 06 Jul 2022 00:48:36 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>Visual Studio Code Development</title>
		<link>https://blog.richliu.com/2021/07/03/4483/visual-studio-code-development/</link>
					<comments>https://blog.richliu.com/2021/07/03/4483/visual-studio-code-development/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 03 Jul 2021 03:14:09 +0000</pubDate>
				<category><![CDATA[隨手札記]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4483</guid>

					<description><![CDATA[<p>個人筆記首先要裝對版本，Visual Studio Code ，不是 Visual Studio commun [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2021/07/03/4483/visual-studio-code-development/">Visual Studio Code Development</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>個人筆記<br />首先要裝對版本，Visual Studio Code ，不是 Visual Studio community 版本，community 沒有 remote development 可以用，不方便</p>



<span id="more-4483"></span>



<h1 class="wp-block-heading">遠端開發</h1>



<p>在 Extension Market 裝 Remote Development, 這套件含 Remote -WSL, Remote &#8211; Container , Remote &#8211; SSH <br />我們要的就是 Remote &#8211; SSH<br /><br />裝完以後，按 F1 輸入(找到) <strong>Remote-SSH:  Add New SSH Host&#8230;</strong><br />輸入你要連結的 HOST，例如：</p>



<pre class="wp-block-preformatted">ssh user@host.example</pre>



<p>接下來選一個 config file ，預設是 c:\user\&lt;your account\.ssh\config<br />選完之後右下角會跳一個視窗，Open Config ，可以打開看一下<br /><br />接下來就選 File -&gt; Preferences -&gt; Setting  ，右上角會有一個 Open Settings(JSON) 的圖示，大概是視窗最大化的那個<br />新安裝的應該什麼設定都沒有，我要連線的目標主機是 Linux ，要加上這個設定</p>



<pre class="wp-block-preformatted">{
&nbsp;&nbsp;&nbsp;&nbsp;"remote.SSH.showLoginTerminal":&nbsp;true,
&nbsp;&nbsp;&nbsp;&nbsp;"remote.SSH.remotePlatform":&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"host.example":&nbsp;"linux",
&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;&nbsp;&nbsp;
}</pre>



<p>接下來就可以連線到 Linux 遠端</p>



<h2 class="wp-block-heading">SSH Keygen</h2>



<p>每次連到遠端都還要輸入密碼也是頗煩的，如果只是不重要的開發機，使用 ssh keygen 還是比較方便的<br /><br />第一步使用 WSL 切到目錄，將 &lt;username> 換成 windows 的帳號，如果 ssh-keygen 產生的 id_rsa 和 id_rsa.pub 沒有在這個目錄，記得copy到這個目錄，最後一步，將 ssh key copy 到你的 server</p>



<pre class="wp-block-preformatted">$ cd /mnt/c/Users/&lt;username>/.ssh
$ ssh-keygen
$ ssh-copy-id &lt;username>@&lt;serverip>
</pre>



<p>這樣就可以用 VS Code 的 SSH Keygen 功能連到遠端了</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2021/07/03/4483/visual-studio-code-development/">Visual Studio Code Development</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2021/07/03/4483/visual-studio-code-development/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Reverse SSH Tunnel</title>
		<link>https://blog.richliu.com/2015/01/08/1733/reverse-ssh-tunnel/</link>
					<comments>https://blog.richliu.com/2015/01/08/1733/reverse-ssh-tunnel/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 08 Jan 2015 14:23:49 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">http://blog.richliu.com/?p=1733</guid>

					<description><![CDATA[<p>這一招很好用, -R Reverse SSH tunnel-N 不要執行遠端命令列-R [bind_addre [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2015/01/08/1733/reverse-ssh-tunnel/">Reverse SSH Tunnel</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>這一招很好用,</p>



<p>-R Reverse SSH tunnel<br />-N 不要執行遠端命令列<br />-R [bind_address:]port:host:hostport] : bind_address 遠端要聽的 IP, Port, 本地要連到的 IP Port</p>



<pre class="wp-block-code"><code>ssh -N -R 10.102.81.1:40000:localhost:40000 user@remote.host.domain</code></pre>



<p>例如遠端機器的內網 IP 是 192.168.1.254 , 想在那個 IP 上開個 port 40000 連回來 ssh 服務，可以用以下的 command <br />加上 -N 是不希望建 tunnel 之後可以使用這個 tunnel 在遠端可以使用 command mode, 如果想要用 command mode 可以將 -N 拿掉</p>



<pre class="wp-block-code"><code>ssh -N -R 192.168.1.254:40000:localhost:22 user@remote.host.domain</code></pre>



<p>不過有時候會有對方 SSH 沒有辦法 bind 在其他 IP 上, 這時候執行 netstat -na | grep 40000 會顯示</p>



<pre class="wp-block-code"><code>tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 127.0.0.1:40000 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN</code></pre>



<p>這要打開遠端 ssh server 的 GatewayPorts, 編輯 /etc/ssh/sshd_config, 加上</p>



<p>GatewayPorts on</p>



<p>重新啟動 sshd 就 OK 了.</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2015/01/08/1733/reverse-ssh-tunnel/">Reverse SSH Tunnel</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2015/01/08/1733/reverse-ssh-tunnel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
