Slide 1

Slide 1 text

Working Remotely Rocks! (via SSH) Kent Chen

Slide 2

Slide 2 text

Kent Chen (chenkaie) chenkaie@gmail.com http://chenkaie.blogspot.com @chenkaie on GitHub @chenkaie on SlideShare @chenkaie on LinkedIn @chenkaie on Twitter @+KentChenAtGoogle on Google+

Slide 3

Slide 3 text

你是否曾經 幻想 過以下畫面 Have you ever dreamed of a scene as the following…

Slide 4

Slide 4 text

© Flickr/veader Working at Starbucks

Slide 5

Slide 5 text

© Flickr/willsteward Working at Coffee Shop

Slide 6

Slide 6 text

© Flickr/kinetic Working at the Beach

Slide 7

Slide 7 text

© Flickr/kinetic Working at the Beach

Slide 8

Slide 8 text

© 37signals Works Remotely Working at Your Sweet House

Slide 9

Slide 9 text

Working at White House

Slide 10

Slide 10 text

© Flickr/sharris Working at Ur Favour Place

Slide 11

Slide 11 text

很不幸 並非談那類的 遠距辦工 Unfortunately, NOT talking that type of “Working Remotely”

Slide 12

Slide 12 text

We Work Remotely https://weworkremotely.com/

Slide 13

Slide 13 text

不願面對的 真相 An Inconvenient TRUTH

Slide 14

Slide 14 text

© Flickr/kent-chen Working at Airport - EVA Air Lounge

Slide 15

Slide 15 text

© Flickr/kent-chen Working at Airport - EVA Air Lounge 俗稱: 放我一馬吧編程

Slide 16

Slide 16 text

當然偶有 小確幸 的一面 Small happiness sometimes.

Slide 17

Slide 17 text

小弟的一些 親身經驗 Personal remote development experience

Slide 18

Slide 18 text

© Flickr/kent-chen Working at Tainan Coffee Shop

Slide 19

Slide 19 text

© Flickr/kent-chen Working at Tainan Coffee Shop 俗稱: 咖啡因編程

Slide 20

Slide 20 text

© Flickr/kent-chen Working with Bears & Wines

Slide 21

Slide 21 text

© Flickr/kent-chen Working with Bears & Wines 俗稱: 微醺編程

Slide 22

Slide 22 text

遠距辦公 の工作狂? An Working Remotely Workaholic?

Slide 23

Slide 23 text

並非 完全 如此 Not exactly, some reasons…

Slide 24

Slide 24 text

臨時 私事處理 Some urgent personal affairs

Slide 25

Slide 25 text

疲勞轟炸の會議 精神不繼 Exhausted whole day long meeting

Slide 26

Slide 26 text

客戶 工作時間配合 Meet customers’ work time

Slide 27

Slide 27 text

哥現在就是 不想寫程式 I just don’t want to coding NOW

Slide 28

Slide 28 text

自我能力 精進 Self Enhancement

Slide 29

Slide 29 text

在家寫程式 我就是覺得 超爽der~~ I feel so productive when coding at home

Slide 30

Slide 30 text

那個來來來...?! Whatever…

Slide 31

Slide 31 text

身為一個 嵌入式系統 軟韌體工程師 Being an Embedded System Engineer

Slide 32

Slide 32 text

我想身上帶塊 開發版 也是合情合理的 You need an EVM board / Development Board on hand

Slide 33

Slide 33 text

所以... 我得搞一塊 開發版回家 So… I have to bring an EVM board home for dev

Slide 34

Slide 34 text

並且搞定完整的 開發環境 And setup a whole development environment including S/W & H/W

Slide 35

Slide 35 text

只是為了解 某個鳥 bug For fixing some a minor issue

Slide 36

Slide 36 text

或是接續 追到一半 的問題 Or for tracing an on-going unfixed issue

Slide 37

Slide 37 text

.

Slide 38

Slide 38 text

..

Slide 39

Slide 39 text

...

Slide 40

Slide 40 text

那未免也太 搞肛 了吧 That’s a bit too bothersome and time-consuming

Slide 41

Slide 41 text

容我介紹一下 可行作法 A feasible approach sharing

Slide 42

Slide 42 text

若能無縫接軌 回內網的 開發除錯環境 What if we can resume last develop/debugging session in the office

Slide 43

Slide 43 text

那就搞定 一半了 That’s ALMOST done

Slide 44

Slide 44 text

內網通常無法由 外部主機連進去 Intranet server generally cannot login from a client through internet

Slide 45

Slide 45 text

我指「通常」 Orz I mean “Generally”…

Slide 46

Slide 46 text

若是被駭了 植入後門 (另當別論) If been Hacked, plant a backdoor That’s another matter

Slide 47

Slide 47 text

常見方法 VPN 虛擬私人網路 VPN is a common feasible solution if available

Slide 48

Slide 48 text

或者是簡易好用的 TeamViewer TeamViewer is also feasible

Slide 49

Slide 49 text

你受得了龜速 TeamViewer TeamViewer suffers high latency =

Slide 50

Slide 50 text

你受得了龜速 TeamViewer TeamViewer suffers high latency =

Slide 51

Slide 51 text

天下武功 無堅不破 唯快不破 FAST - short network latency is a MUST for basic development env.

Slide 52

Slide 52 text

對程師設計師而言 「快」 使用者體驗:贊 FAST: Great UX for programmer

Slide 53

Slide 53 text

建立反向 SSH Tunnel 可以幹許多 有趣的壞事 Well-known Reverse SSH Tunnel

Slide 54

Slide 54 text

Basic Requirement ! • 24-Hours online SSH server: • DD-WRT Router / VPC (Amazon EC2) / NAS / 
 A development board / … • With Public Access IP: • Fixed IP (Trivial) • Dynamic IP (DDNS) • SSH Client: • Mac OS X / Linux Distributions (Prefer Unix- based) • Windows (putty, plink) • Not too poor upload/download network bandwidth

Slide 55

Slide 55 text

至於打通手法 Goolge it, BJ4 Lots of tutorial, no explanation “Remote Port Forwarding” on 22 Ref: http://josephj.com/entry.php?id=312

Slide 56

Slide 56 text

我只能說: 建議搭配服用 “Autossh / expect” & “SSH Public Key Authentication” 效果加乘 Employ with “autossh / expect” to get persistent connection

Slide 57

Slide 57 text

需要 Customer Support 請撥底下分機 0800-092-000 If you need help, please call me

Slide 58

Slide 58 text

透過該 暗黑魔法 打通後 Once successfully setup a Reverse SSH Tunnel

Slide 59

Slide 59 text

Working remotely through Reverse SSH Tunnel

Slide 60

Slide 60 text

Working remotely through Reverse SSH Tunnel Joker: You see dead people. Hey you, get the job done. Or…

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

強烈建議轉職為 CLI 職人 Command-Line Interface Strongly suggested to be addicted to CLI operation on all you development jobs

Slide 63

Slide 63 text

Me an embedded system developer daily using CLI utilities ! • Editor: vim • VCS/SCM: git / svn • Diff/Merge: vimdiff / DirDiff (vim) • Terminal Multiplexer: tmux • File search: find / godir() • pattern matching: grep / aj / gid (ID Utils) Ref: Vim Rocks! http://www.slideshare.net/chenkaie/vim-rocks TMUX Rocks! http://www.slideshare.net/chenkaie/tmux-rocks

Slide 64

Slide 64 text

CLI 職人(魔人) 遠距開發 益處多多 An amazing lot of advantages if you dev remotely with pure CLI

Slide 65

Slide 65 text

! 優點一 Pros 1

Slide 66

Slide 66 text

頻寬需求低 反應速度快 Lower bandwidth demand Instant keystroke response

Slide 67

Slide 67 text

! 優點二 Pros 2

Slide 68

Slide 68 text

「終端复用器 tmux」 + 「命令列魔人 CLI」 With the assistance of terminal multiplexer: tmux & CLI

Slide 69

Slide 69 text

任意地點、任意終端 一致性 不間斷完整開發環境 Consistent & Persistent development environment from any location any client

Slide 70

Slide 70 text

! 優點三 Pros 3

Slide 71

Slide 71 text

容易建置、部署 一致性開發環境 Consistency dev environment easily setup on different machines even different platforms Ref: https://github.com/chenkaie/manifest-unix-env-deploy

Slide 72

Slide 72 text

有時候會需要存取 內網服務 Sometimes you have demands to access other intranet service

Slide 73

Slide 73 text

那就建立 SOCKS v4/v5 Proxy Server Use “ssh -D” to setup SOCKS Server Ref: http://josephj.com/entry.php?id=312

Slide 74

Slide 74 text

Redmine Wiki Bugzilla WebMail Private IP Host Private IP Device Don’t worry, all are easily accessible

Slide 75

Slide 75 text

Chrome 請搭配 “Proxy SwitchySharp” Firefox 請搭配 “FoxyProxy” 讓你無痛又無縫切換 Proxy Use browser plugin/extension to seamlessly switch between different proxy

Slide 76

Slide 76 text

Chrome + SwitchySharp (Auto Switch Mode: Domain)

Slide 77

Slide 77 text

Chrome + SwitchySharp (Auto Switch Mode: IP Address)

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

有人提問: 啊…那個純CLI下 Streaming 怎麼連勒 How to connect rtsp streaming under CLI mode

Slide 80

Slide 80 text

RTSP streaming connection via CLI: avconv avconv (ffmpeg): $ avconv -rtsp_transport tcp -i "rtsp://root@172.16.81.61/live.sdp" -vcodec copy ~/tmp/test.mp4

Slide 81

Slide 81 text

RTSP streaming connection via CLI: avplay avplay (ffplay): $ avplay -rtsp_transport tcp -i "rtsp://root@172.16.81.61/live.sdp"

Slide 82

Slide 82 text

又有人說: 嵌入式系統開發 沒 Console 可用 說得過嗎(翻桌) Embedded System development w/o Console?!

Slide 83

Slide 83 text

$ cat /proc/kmsg (a poor solution)

Slide 84

Slide 84 text

路人甲說: 沒有 IW2 可用 怎麼找 IP Camera 勒 How to search a IP Cam without IW2

Slide 85

Slide 85 text

請愛用強大的 ”IW2 Air” Awesome “IW2 Air” just works

Slide 86

Slide 86 text

最後有人忍不住說: 哥就是要視窗操作啦 Desktop / X-Window I just want to use GUI desktop environment

Slide 87

Slide 87 text

好懷念菸酒生時期透過 Windows遠端桌面 連回LAB的低延遲速度感 Low latency remote control experience on “Microsoft Remote Desktop”

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

往事只能回味 真的回不去了嗎? “Microsoft Remote Desktop” No longer available under NAT?

Slide 91

Slide 91 text

先讓我們搞懂 (RDP) Remote Desktop Protocol Ref: http://en.wikipedia.org/wiki/Remote_Desktop_Protocol

Slide 92

Slide 92 text

如法炮製試試 Port: 3389 What if we do “Remote Port Forwarding” on port 3389?

Slide 93

Slide 93 text

Test: You can test by below command to check if successfully forwarded? $ telnet ! Setup: Fill in the corresponding forwarded “Domain:Port” as right figure.

Slide 94

Slide 94 text

And… :)

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

原理就是這麼簡單 若有其它需求請 如法炮製 Follow above example to Forward Any Port you want

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

Reference Remote Development http://crosbymichael.com/remote-development.html Why We (Still) Believe in Working Remotely http://blog.stackoverflow.com/2013/02/why-we-still-believe-in- working-remotely/ 37signals Works Remotely http://37signals.com/remote/ Coffitivity - Increase Your Creativity! http://www.coffitivity.com/

Slide 99

Slide 99 text

Reference 反向建⽴立 SSH Tunnel、免 VPN 連回公司 http://josephj.com/entry.php?id=312 Mosh (mobile shell) http://mosh.mit.edu/ Vim Rocks! http://www.slideshare.net/chenkaie/vim-rocks TMUX Rocks! http://www.slideshare.net/chenkaie/tmux-rocks subversion-scripts (Throw away TortoiseSVN) https://github.com/chenkaie/Tools/tree/master/subversion-scripts