<?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>Dev Tool &#8211; Gary&#039;s &#8230;Lasamia</title>
	<atom:link href="https://garynil.tw/tag/dev-tool/feed/" rel="self" type="application/rss+xml" />
	<link>https://garynil.tw</link>
	<description>🍎 📱 🖥 🔨 😄</description>
	<lastBuildDate>Sat, 16 Oct 2021 13:14:50 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.3</generator>

<image>
	<url>https://i0.wp.com/garynil.tw/wp-content/uploads/2017/01/cropped-Gary_v3.0.jpg?fit=32%2C32&#038;ssl=1</url>
	<title>Dev Tool &#8211; Gary&#039;s &#8230;Lasamia</title>
	<link>https://garynil.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">147732124</site>	<item>
		<title>透過 USB 傳輸線 SSH 進入 iPhone 等 iDevice</title>
		<link>https://garynil.tw/2016/12/255/%e9%80%8f%e9%81%8e-usb-%e5%82%b3%e8%bc%b8%e7%b7%9a-ssh-%e9%80%b2%e5%85%a5-iphone-%e7%ad%89-idevice/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e9%2580%258f%25e9%2581%258e-usb-%25e5%2582%25b3%25e8%25bc%25b8%25e7%25b7%259a-ssh-%25e9%2580%25b2%25e5%2585%25a5-iphone-%25e7%25ad%2589-idevice</link>
					<comments>https://garynil.tw/2016/12/255/%e9%80%8f%e9%81%8e-usb-%e5%82%b3%e8%bc%b8%e7%b7%9a-ssh-%e9%80%b2%e5%85%a5-iphone-%e7%ad%89-idevice/#respond</comments>
		
		<dc:creator><![CDATA[Gary]]></dc:creator>
		<pubDate>Sat, 31 Dec 2016 14:34:37 +0000</pubDate>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Dev Tool]]></category>
		<category><![CDATA[iDevice]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[USB]]></category>
		<guid isPermaLink="false">https://garynil.tw/?p=255</guid>

					<description><![CDATA[<p>有在開發或使用 SSH (Secure Shell) 登入 iPhone 等 iDevice 的人一定會遇到這些情況 出門在外，沒有 wifi 卻需要 SSH 登入 iPhone 有時將 iPhone 連上個不常使用的 Wifi 熱點，想要 SSH 登入時還要特地去設置然後找 IP 經過頗多步驟 這些等等等的情況，其實都有個簡單的方式可以解決， 就是透過你一定擁有的 iPhone 傳輸線，簡單的透過傳輸線將 iPhone 接到你的電腦的 USB port，就可以很方便的 SSH 進入 需求 iDevice 設備 具有資料傳輸功能的傳輸線 (接上電腦，iTunes可以正常偵測到你的 iDevice 即可) 具有 USB port 的電腦 (Type-C也可啦..XD) iDevice 上需要安裝 OpenSSH 而要透過什麼來完成這項目的呢？其實透過一套網路上的 Library：usbmux...</p>
<p>這篇文章 <a rel="nofollow" href="https://garynil.tw/2016/12/255/%e9%80%8f%e9%81%8e-usb-%e5%82%b3%e8%bc%b8%e7%b7%9a-ssh-%e9%80%b2%e5%85%a5-iphone-%e7%ad%89-idevice/">透過 USB 傳輸線 SSH 進入 iPhone 等 iDevice</a> 最早出現於 <a rel="nofollow" href="https://garynil.tw">Gary&#039;s ...Lasamia</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>有在開發或使用 SSH (Secure Shell) 登入 iPhone 等 iDevice 的人一定會遇到這些情況</p>
<ul>
<li>出門在外，沒有 wifi 卻需要 SSH 登入 iPhone</li>
<li>有時將 iPhone 連上個不常使用的 Wifi 熱點，想要 SSH 登入時還要特地去設置然後找 IP 經過頗多步驟</li>
</ul>
<p>這些等等等的情況，其實都有個簡單的方式可以解決，<br />
就是透過你一定擁有的 iPhone 傳輸線，簡單的透過傳輸線將 iPhone 接到你的電腦的 USB port，就可以很方便的 SSH 進入<br />
<span id="more-255"></span></p>
<h3>需求</h3>
<ul>
<li>iDevice 設備</li>
<li>具有資料傳輸功能的傳輸線 (接上電腦，iTunes可以正常偵測到你的 iDevice 即可)</li>
<li>具有 USB port 的電腦 (Type-C也可啦..XD)</li>
<li>iDevice 上需要安裝 OpenSSH</li>
</ul>
<p>而要透過什麼來完成這項目的呢？其實透過一套網路上的 Library：<a href="https://github.com/libimobiledevice/usbmuxd" target="_blank" rel="noopener">usbmuxd</a></p>
<p>安裝方式很簡單，下載來使用即可：<a href="http://pkgs.fedoraproject.org/repo/pkgs/usbmuxd/" target="_blank" rel="noopener">官方連結</a><br />
但有版本差異，最新 1.1.0 必須透過複雜的安裝方式，所以我是下載 <a href="http://pkgs.fedoraproject.org/repo/pkgs/usbmuxd/usbmuxd-1.0.6.tar.bz2/c8909cfd9253d8d1a5e26f2ff7e5908b/usbmuxd-1.0.6.tar.bz2" target="_blank" rel="noopener">1.0.6</a> 版本可以直接執行</p>
<p>透過 curl 指令下載<br />
<code>$ curl -OL http://pkgs.fedoraproject.org/repo/pkgs/usbmuxd/usbmuxd-1.0.6.tar.bz2/c8909cfd9253d8d1a5e26f2ff7e5908b/usbmuxd-1.0.6.tar.bz2</code></p>
<p>放置指定路徑然後解壓縮<br />
<code>$ tar jxvf usbmuxd-1.0.6.tar.bz2</code></p>
<p>移動至內部一個 pytohn-client 的資料夾內<br />
<code>$ cd ./usbmuxd-1.0.6/python-client</code></p>
<p>這裡要注意的是，要先將 tcprelay.py 這個檔案改權限並更動為可執行，一般使用者才可以正常執行<br />
<code>$ chmod +x tcprelay.py</code></p>
<p>然後就可以透過這串指令來開啟 USB port forward 了！<br />
<code>$ ./tcprelay.py -t 22:2222</code><br />
<img data-recalc-dims="1" fetchpriority="high" decoding="async" data-attachment-id="14293" data-permalink="https://garynil.tw/2016/12/255/%e9%80%8f%e9%81%8e-usb-%e5%82%b3%e8%bc%b8%e7%b7%9a-ssh-%e9%80%b2%e5%85%a5-iphone-%e7%ad%89-idevice/31854892682_79493a38df_z/" data-orig-file="https://i0.wp.com/garynil.tw/wp-content/uploads/2016/12/31854892682_79493a38df_z.jpg?fit=640%2C506&amp;ssl=1" data-orig-size="640,506" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="31854892682_79493a38df_z" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/garynil.tw/wp-content/uploads/2016/12/31854892682_79493a38df_z.jpg?fit=640%2C506&amp;ssl=1" src="https://i0.wp.com/garynil.tw/wp-content/uploads/2016/12/31854892682_79493a38df_z.jpg?resize=640%2C506&#038;ssl=1" alt="" width="640" height="506" class="aligncenter size-full wp-image-14293" /><br />
開啟之後，這時你就可以透過 SSH 來登入了！<br />
<code>ssh root@localhost -p 2222</code></p>
<p>當然，每次都要 cd 到指定位置然後執行一串指令非常麻煩<br />
所以可以簡化成一步驟</p>
<p>1.可以將以下這個路徑設置至你所使用預設 shell 內 (Bash 或 ZSH 等)，我是使用ZSH，因此是改動 ~/.zshrc</p>
<p><code>export USBPort=/你放置資料夾的路徑/usbmuxd/python-client/</code></p>
<p>之後你便可以在終端機內 使用 <code>$USBPort/tcprelay.py -t 22:2222</code> 這快速的捷徑路徑，不用在自己慢慢找</p>
<p>2.更偷懶可以透過 <a href="https://textexpander.com" target="_blank" rel="noopener">Text Expander</a> 然後快速輸入上面那串&#8230;</p>
<p>這篇文章 <a rel="nofollow" href="https://garynil.tw/2016/12/255/%e9%80%8f%e9%81%8e-usb-%e5%82%b3%e8%bc%b8%e7%b7%9a-ssh-%e9%80%b2%e5%85%a5-iphone-%e7%ad%89-idevice/">透過 USB 傳輸線 SSH 進入 iPhone 等 iDevice</a> 最早出現於 <a rel="nofollow" href="https://garynil.tw">Gary&#039;s ...Lasamia</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://garynil.tw/2016/12/255/%e9%80%8f%e9%81%8e-usb-%e5%82%b3%e8%bc%b8%e7%b7%9a-ssh-%e9%80%b2%e5%85%a5-iphone-%e7%ad%89-idevice/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">255</post-id>	</item>
		<item>
		<title>免密碼登入ssh</title>
		<link>https://garynil.tw/2016/12/163/%e5%85%8d%e5%af%86%e7%a2%bc%e7%99%bb%e5%85%a5ssh/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%2585%258d%25e5%25af%2586%25e7%25a2%25bc%25e7%2599%25bb%25e5%2585%25a5ssh</link>
					<comments>https://garynil.tw/2016/12/163/%e5%85%8d%e5%af%86%e7%a2%bc%e7%99%bb%e5%85%a5ssh/#comments</comments>
		
		<dc:creator><![CDATA[Gary]]></dc:creator>
		<pubDate>Mon, 26 Dec 2016 06:19:11 +0000</pubDate>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Dev Tool]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Terminal]]></category>
		<guid isPermaLink="false">https://garynil.tw/?p=163</guid>

					<description><![CDATA[<p>相信大家有類似的經驗，在使用 SSH 登入，往往都要輸入密碼，但是常用主機如果設置的是亂碼或者複雜性密碼，每次都要輸入一次頗為不便 又或者有些情況下想要免密碼登入 (便利性、rsync、script操作) ，這時候透過金鑰達成免密碼登入會便利很多！ 那以下步驟以機器A、機器B來稱呼兩台主機： 機器 A (Client) 為你正在操作的電腦，透過終端機操作 SSH 指令 機器 B (Server) 為你使用 SSH 登入的遠端的主機 步驟一：產生公鑰 首先，你需要在機器 A (Client) 產生給機器B (Server) 主機使用的金鑰組 $ ssh-keygen -t rsa 圖 金鑰組則會有兩個檔案：公鑰 (public key) 、私鑰 (private key) 一般來說，公鑰 (public key) 的路徑及檔名會像是這樣： ~/.ssh/id_rsa.pub 而私鑰 (pri...</p>
<p>這篇文章 <a rel="nofollow" href="https://garynil.tw/2016/12/163/%e5%85%8d%e5%af%86%e7%a2%bc%e7%99%bb%e5%85%a5ssh/">免密碼登入ssh</a> 最早出現於 <a rel="nofollow" href="https://garynil.tw">Gary&#039;s ...Lasamia</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>相信大家有類似的經驗，在使用 SSH 登入，往往都要輸入密碼，但是常用主機如果設置的是亂碼或者複雜性密碼，每次都要輸入一次頗為不便<br />
又或者有些情況下想要免密碼登入 (便利性、rsync、script操作) ，這時候透過金鑰達成免密碼登入會便利很多！</p>
<p>那以下步驟以機器A、機器B來稱呼兩台主機：<br />
機器 A (Client) 為你正在操作的電腦，透過終端機操作 SSH 指令<br />
機器 B (Server) 為你使用 SSH 登入的遠端的主機</p>
<p><span id="more-163"></span></p>
<h3>步驟一：產生公鑰</h3>
<p>首先，你需要在機器 A (Client) 產生給機器B (Server) 主機使用的金鑰組</p>
<p><code>$ ssh-keygen -t rsa</code></p>
<p>圖<br />
金鑰組則會有兩個檔案：公鑰 (public key) 、私鑰 (private key)<br />
一般來說，公鑰 (public key) 的路徑及檔名會像是這樣：<br />
<code>~/.ssh/id_rsa.pub</code></p>
<p>而私鑰 (private key) 的則是會像是這樣：<br />
<code>~/.ssh/id_rsa</code></p>
<p>這些檔案因為安全性當然不要外流。</p>
<h3>步驟二：複製公鑰至主機，加入主機的信任清單中</h3>
<p>將剛剛產生的 public key (id_rsa.pub) 透過 SCP 指令拷貝到機器 B (Server) 中，加入你所擁有帳號之下的 .ssh/authorized_keys 中</p>
<p><code>$ scp -P <strong>'server-Port'</strong> ~/.ssh/id_rsa.pub <strong>'server-User@server-IP'</strong>:~/id_rsa.pub</code><br />
範例：<br />
<code>scp -P 2222 ~/.ssh/id_rsa.pub root@localhost:~/id_rsa.pub</code></p>
<p>之後在 SSH 進入你的主機，在主機內輸入</p>
<p><code>cat id_rsa.pub >> .ssh/authorized_keys</code></p>
<p>如果出現沒有 authorized_keys 的話：<br />
<code>touch ~/.ssh/authorized_keys</code></p>
<p><code>chmod 600 .ssh/authorized_keys</code><br />
移動至目標位置然後改到對應的權限即可</p>
<p>註1：這邊要確認你的主機端有安裝 SSH 以及 SCP 指令，有遇過 iOS 10 Jailbreak 裝置沒有預設安裝的狀況XD<br />
註2：如果機器 B (Server) 你所擁有的帳號沒有 .ssh/authorized_keys 的路徑，在你複製時會直接顯示錯誤，解決方法是先透過 SSH 登入至 機器 B，並執行開創.ssh資料夾的動作 <code>mkdir .ssh</code> 便會產生相關路徑。<br />
註3：偷懶法：<code>ssh-copy-id -i root@ip_address</code></p>
<h3>延伸應用：</h3>
<ol>
<li>步驟一產生的金鑰如果可供任意寫入頗為危險，因此有些人會改掉相關檔案的權限</li>
</ol>
<p><code>$ ssh 'server-User@server-IP'</code><br />
<code>$ chmod 400 ~/.ssh/authorized_keys #關閉存取</code></p>
<p>如果要打開存取用下列指令就可以了：<br />
<code>$ chmod 600 ~/.ssh/authorized_keys #可供寫入</code></p>
<p>參考來源：<a href="http://gwokae.mewggle.com/wordpress/2010/08/超易-兩行指令搞定-linux-ssh登入免密碼/#step1-key-pair-genSH登入免密碼" target="_blank">LinXblog [超易] 兩行指令搞定 Linux SSH登入免密碼</a></p>
<ol>
<li>關閉主機密碼登入<br />
因為安全性，有些人會將主機的密碼登入功能關閉，主機僅會比對金鑰以供登入<br />
而要達成這項功能，只允許使用金鑰來做登入，可以修改以下這個檔案的兩個參數：</li>
</ol>
<p><code>$ vim /etc/ssh/sshd_config</code><br />
將<br />
<code>PubkeyAuthentication yes</code><br />
<code>PasswordAuthentication no</code><br />
設為對應的值就可以完成了</p>
<p>參考來源：<a href="https://blog.longwin.com.tw/2005/12/ssh_keygen_no_passwd/" target="_blank">Tsung&#8217;s Blog ssh keygen 免輸入密碼</a></p>
<p>這篇文章 <a rel="nofollow" href="https://garynil.tw/2016/12/163/%e5%85%8d%e5%af%86%e7%a2%bc%e7%99%bb%e5%85%a5ssh/">免密碼登入ssh</a> 最早出現於 <a rel="nofollow" href="https://garynil.tw">Gary&#039;s ...Lasamia</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://garynil.tw/2016/12/163/%e5%85%8d%e5%af%86%e7%a2%bc%e7%99%bb%e5%85%a5ssh/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">163</post-id>	</item>
	</channel>
</rss>
