<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tristan Wu on Medium]]></title>
        <description><![CDATA[Stories by Tristan Wu on Medium]]></description>
        <link>https://medium.com/@wuzhenquan?source=rss-40e673174a99------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xC4-ALWrgsi5SMwHCqN8TQ.jpeg</url>
            <title>Stories by Tristan Wu on Medium</title>
            <link>https://medium.com/@wuzhenquan?source=rss-40e673174a99------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:58:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wuzhenquan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dynamic IP Solutions — Duck DNS Setup]]></title>
            <link>https://medium.com/@wuzhenquan/dynamic-ip-solutions-duck-dns-setup-e3bd14a024d7?source=rss-40e673174a99------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3bd14a024d7</guid>
            <category><![CDATA[freedns]]></category>
            <category><![CDATA[dynamic-ip]]></category>
            <category><![CDATA[ddns]]></category>
            <dc:creator><![CDATA[Tristan Wu]]></dc:creator>
            <pubDate>Mon, 22 Apr 2024 04:23:15 GMT</pubDate>
            <atom:updated>2024-04-22T12:05:43.194Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dynamic IP Solutions — Duck DNS Setup</h3><p>My home server’s public IP address changes over time. Therefore, I decided to use the Dynamic Domain Name System (DDNS) service to track my server’s public IP, to avoid the need to track changing IP addresses manually.</p><p>I found that Duck DNS is free and easy to set up. The installation was completed in just ten minutes from scratch.</p><h3>Step 1: Creating a Duck DNS account</h3><p>Go to <a href="https://www.duckdns.org/">Duck DNS website homepage</a> and sign in.</p><figure><img alt="Duck DNS website home page" src="https://cdn-images-1.medium.com/max/1024/1*1A7tstQ6k_TBpDxkElp7Tw.png" /><figcaption>Duck DNS website homepage</figcaption></figure><h3>Step 2: Create a subdomain name</h3><p>Think of your own subdomain name, type your subdomain name into the <a href="https://www.duckdns.org/">Duck DNS website homepage</a> and then click the “add domain” button.</p><figure><img alt="Subdomain editing" src="https://cdn-images-1.medium.com/max/838/1*zph_3UdfwQpRggA1l4HyQw.png" /><figcaption>The subdomain name “myhomeserver” was typed into Duck DNS homepage.</figcaption></figure><h3>Step 3: Create a script</h3><p>Create directory ~/duckdns and file ~/duckdns/duck.sh :</p><pre>mkdir ~/duckdns<br>cd ~/duckdns<br>touch duck.sh</pre><figure><img alt="Duck DNS update script file" src="https://cdn-images-1.medium.com/max/842/1*CSwclvjYCzjLRjRDppRSIw.png" /><figcaption>The location of my Duck DNS update script file.</figcaption></figure><h3>Step 4: Edit the script</h3><p>Go to the <a href="https://www.duckdns.org/install.jsp">Duck DNS — install</a> webpage, sign in, and click the “choose subdomain” to select a subdomain of you choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HchX-Om9S8niuRrQZ-G55A.png" /></figure><p>Next, copy the provided code from the webpage <a href="https://www.duckdns.org/install.jsp">Duck DNS — install</a>, paste it into the `~/duckdns/duck.sh` file, and then save the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KRRq_YjuTJweMcwx-AFehg.png" /><figcaption>My duck.sh script contains code copied from <a href="https://www.duckdns.org/install.jsp">https://www.duckdns.org/install.jsp</a>.</figcaption></figure><h3>Step 5: Make the script executable</h3><p>Run the following command on your home server to make ~/duckdns/duck.sh executable:</p><pre>chmod 700 ~/duckdns/duck.sh</pre><h3>Step 6: Run and Test the script</h3><p>Run the script:</p><pre>~/duckdns/duck.sh</pre><p>Test the script:</p><pre>cat ~/duckdns/duck.log</pre><p>If the output contains `OK`, the public IP has been successfully updated on Duck DNS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*mW6Ua3gVrly6HK2D4GRStg.png" /><figcaption>The output result of testing the duck.sh script.</figcaption></figure><h3>Step 7: use cron to run the script automatically</h3><p>Run the following command to edit the cron file:</p><pre>crontab -e</pre><p>It will open the default text editor with the contents of your user’s crontab file.</p><p>Add the code below:</p><pre>*/5 * * * * ~/duckdns/duck.sh &gt;/dev/null 2&gt;&amp;1</pre><p>Save and exit the file after making your changes. Now, the ~/duckdns/duck.sh file will be scheduled to run every 5 minutes.</p><h3>Summary</h3><p>Below are the brief steps outlined previously:</p><ol><li>Create a DuckDNS account.</li><li>Create update script ~/duckdns/duck.sh.</li><li>Use cron utility to run the update script automatically.</li></ol><h3>Troubleshooting VPN Connection Issues</h3><p>I have set up a VPN on my home server before, then I noticed that the updated IP on my Duck DNS account does not match my actual public IP. This is because the Duck DNS API request is proxied through my VPN service. Configuring the proxy rules should solve the issue.</p><p>Here’s a solution for my <a href="https://github.com/juewuy/ShellCrash">ShellCrash</a> service:</p><ol><li>Edit the Crash configuration file `config.yaml`.</li><li>Insert DOMAIN-SUFFIX,duckdns.org,DIRECT below the rules: line, then save the file and exit.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*2B4M6xbReSYdfuphXwFykA.png" /><figcaption>The ShellCrash config file.</figcaption></figure><h3>Q &amp; A</h3><p>Q: What is DNS? A: It’s an internet’s phonebook. Translate domain names into static IP addresses.</p><p>Q: What is DDNS? A: It’s also an internet’s phonebook. But the IP address is frequently auto changing.</p><p>Q: What is a subdomain? A: The duckdns.com is a root domain. The myhomeserver.duckdns.com is a subdomain for duckdns.com.</p><p>Q: What is cron? A: It’s a Linux utility used to run scripts at scheduled times.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3bd14a024d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSH to Your Remote Server without IP]]></title>
            <link>https://medium.com/@wuzhenquan/ssh-to-your-remote-server-without-ip-5b868a773e50?source=rss-40e673174a99------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b868a773e50</guid>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Tristan Wu]]></dc:creator>
            <pubDate>Fri, 22 Mar 2024 03:18:59 GMT</pubDate>
            <atom:updated>2024-05-11T05:09:29.769Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is a step-by-step based on the article <a href="https://medium.com/@wuzhenquan/windows-and-wsl-2-setup-for-ssh-remote-access-013955b2f421">WSL 2 Setup for SSH Remote Access</a>. It doesn’t intend to provide in-depth details about the SSH Remote procedure. Keeping the steps straightforward may help better understanding of SSH Basics.</p><h3>Checking on the remote server</h3><h4>✅ Ensure the SSH service is running</h4><p>Check the status of the SSH service:</p><pre>sudo systemctl status ssh</pre><p>The output shows the status info of the SSH service, with the text Active:active(running) indicating that the SSH service is running on the server.</p><h4>✅ Check the SSH port number</h4><p>Keeping the default SSH port at 22 is convenient for personal use if security isn’t a concern.</p><p>So let’s check the SSH configuration file that contains the port number:</p><pre>grep Port /etc/ssh/sshd_config</pre><p>The following output indicates that the SSH service is listening on the default port 22.</p><pre>#Port 22</pre><h4>✅ Find the `&lt;remote_server_username&gt;`</h4><p>Run the following command:</p><pre>whoami</pre><p>👇 It will print out the username:</p><pre>train # ← This is my `&lt;remote_server_username&gt;`</pre><h4>✅ Find the public IP address as `&lt;remote_server_public_ip&gt;`</h4><p>Run the following command:</p><pre>curl https://icanhazip.com</pre><p>It will print out the public IP of my server: 👇🏻</p><pre>172.16.254.31 # ← This is the `&lt;remote_server_public_ip&gt;`</pre><h3>Checking on the Local Machine</h3><h4>✅ Generate SSH Key Pair:</h4><p>Run the following command:</p><pre>ssh-keygen</pre><h4>✅ Authenticate local machine to remote machine</h4><p>Run the following command:</p><pre>ssh-copy-id &lt;remote_server_username&gt;@&lt;remote_server_public_ip&gt; </pre><p>The two variables &lt;remote_server_username&gt; and &lt;remote_server_ip&gt; were mentioned before.</p><p>It’s my first time connecting to the remote server. My SSH client displays a prompt about the remote server’s authenticity and fingerprint information.</p><pre>The authenticity of host &#39;&lt;remote_server_public_ip&gt; (&lt;remote_server_public_ip&gt;)&#39; can&#39;t be established.<br>ECDSA key fingerprint is SHA256:Jw/3FIJwpp3FIJw/3FIJw/3FppLVppmjWs.<br>Are you sure you want to continue connecting (yes/no/[fingerprint])?</pre><p>Typing yes and pressing Enter will:<br>- Allow the SSH client to accept the remote server’s host key.<br>- Add the remote server’s host key to the know_host file in my local machine’s .ssh directory.</p><p>Then my SSH client display another prompt for requiring to enter the password.</p><pre>&lt;remote_server_username&gt;@&lt;remote_server_public_ip&gt;&#39;s password:</pre><p>After entering the correct password just one time, ssh-copy-id copies my public key to the remote server’s ~/.ssh/authorized_keys file. And I will never entering password when I want to connect server with SSH.</p><h3>Connect Remote Server</h3><p>Run the following command:</p><pre>ssh &lt;remote_server_username&gt;@&lt;remote_server_public_ip&gt;</pre><h3>SSH Login without the IP</h3><h4>✅ Editing SSH config file</h4><p>1️⃣ Create ~/.shh/config file, or edit it if the file exists.</p><p>2️⃣ Use the following format to add my &lt;alias_name&gt;, &lt;remote_serer_public_up&gt;, &lt;remote_server_username&gt;.</p><pre>Host &lt;alias_name&gt;<br> HostName &lt;remote_server_public_ip&gt;<br> User &lt;remote_server_username&gt;</pre><p>3️⃣ save the file.</p><h4>✅ Connecting Only with Alias Name</h4><p>Just typing ssh &lt;alias_name&gt; on the local machine allows me to connect my remote server without having to remember any of its details from now on! Quite a relief for the mental burden, right?</p><h3>Summary</h3><p>The content above covered the steps and detailed explanations. Now, let’s briefly review all the steps for a quick setup in a real-world environment.</p><p>Preparation checklist:<br>- The &lt;remote_server_username: such as train<br>- The &lt;remote_server_public_ip&gt;: such as 172.16.254.31<br>- The SSH &lt;alias_name&gt;: such as mylinuxlab</p><p>Step 1: Run sudo systemctl status ssh.</p><p>Step 2: Run ssh-keygen.</p><p>Step 3: Run ssh-copy-id train@172.16.253.31.</p><p>Step 4: Edit file ~/.ssh/config as following and save it.</p><pre>Host mylinuxlab<br> HostName 172.16.254.31<br> User train</pre><p>Step 5: Run ssh mylinuxlab.</p><p>Step 6: Close SSH connection by typing exit and Enter.</p><h3>So I Think I Know SSH?</h3><p>Connecting to a remote server using SSH is relatively straightforward.</p><p>However, the scenario becomes more complex when looking into aspects such as configuration, and security.</p><p>If I want to get the hang of SSH skills, the next aspects of SSH knowledge I should learn include:<br>- Learn how to configure the SSH config file.<br>- Learn common SSH options.<br>- Grasp SSH security best practices.</p><p>Maybe the title of my next article about SSH will be “So I Think Know SSH” 😃😃😃.</p><h3>Q &amp; A</h3><h4>Q: what is `systemctl` ?</h4><p>A: systemctl is a command line to control and manage the systemd system. The ctl stands for “control”.</p><h4>Q: What does `ssh-keygen` do?</h4><p>A: It generates an RSA key pair by default. This key pair contains a public key and a private key, which are stored in ~/.ssh/ directory.</p><h4>Q: what are `~/.ssh/id_rsa.pub` and `~/.ssh/id_rsa`?</h4><p>A: ~/.ssh/id_rsa.pub and~/.ssh/id_rsa are the public and private keys generated by running ssh-keygen.</p><p>The local machine’s public key is used to be shared and copied to the SSH service of the remote server.</p><p>The local machine’s private key is used to authenticate the local machine to the remote systems that have the local machine’s public key.</p><h4>Q: What is `sshd`?</h4><p>A: The sshd stands for OpenSSH Server Daemon.</p><h4>Q: What is `/etc/ssh/sshd_config`?</h4><p>A: It is a configuration file for the sshd.</p><h4>Q: What does `ssh-copy-id` do?</h4><p>A: It will copy the local public key to the autorized_keys file on the remote server.</p><h4>Q: How to close the SSH connection?</h4><p>A: Type ssh and press Enter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b868a773e50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSL 2 Setup for SSH Remote Access]]></title>
            <link>https://medium.com/@wuzhenquan/windows-and-wsl-2-setup-for-ssh-remote-access-013955b2f421?source=rss-40e673174a99------2</link>
            <guid isPermaLink="false">https://medium.com/p/013955b2f421</guid>
            <category><![CDATA[windows-linux]]></category>
            <category><![CDATA[remote-ssh]]></category>
            <category><![CDATA[wsl-2]]></category>
            <category><![CDATA[wslinux]]></category>
            <dc:creator><![CDATA[Tristan Wu]]></dc:creator>
            <pubDate>Wed, 20 Dec 2023 03:08:09 GMT</pubDate>
            <atom:updated>2024-05-13T06:53:11.027Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_2">WSL 2</a> is an abbreviation for <a href="https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux">Windows Subsystem for Linux</a>. Using WSL 2 for development would be a good way to ensure a stable environment. If you want to try WSL as a mini Linux server, this article might serve as a guide for you.</p><h3>Reinstalling SSH</h3><ul><li>Uninstall: sudo apt remove openssh-server</li><li>Reinstall: sudo apt install openssh-server</li></ul><p><strong>Configuring SSH</strong></p><ul><li>Open SSH config file: sudo vi /etc/ssh/sshd_config</li><li>Change #Port 22 to Port 22 to enable the default port.</li><li>Change #PasswordAuthentication yes to PasswordAuthentication yes to enable password authentication.</li></ul><h4>Restarting the SSH Service</h4><pre>sudo service ssh restart</pre><h4>Testing SSH Connection</h4><pre>systemctl status sshd</pre><h3>Setting Up Port Forwarding for Remote Access</h3><h4>Run Network Shell Port Forwarding Command</h4><p>What we need to do is to configure the Windows system to listen on a specific port and redirect incoming traffic from that port to a different port. Run the following command in PowerShell.</p><pre>netsh interface portproxy add v4tov4 `<br>  listenaddress=&lt;windows_local_ip&gt; `<br>  listenport=&lt;listen_port_on_windows&gt; ` # Any unused port number<br>  connectaddress=&lt;wsl_internal_ip&gt; `<br>  connectport=&lt;ssh_service_port&gt;        </pre><h4>Questions and Answers</h4><p>Q: Why is setting up port forwarding on Windows necessary?<br>A: <br> - Because the WSL 2 VM has its own separate network adapter. <br> - Because the WSL 2 VM IP address is only reachable from the Windows host machine, not reachable from other devices on your local network.<br> - Because the network settings and IP addresses you see on the Windows vEthernet adapter associated with WSL 2 are not exposed to the local network through the same subnet as your physical network.</p><p>Q: How to find my Windows IP address?<br>A: <br>Open PowerShell and run the command ipconfig. Look for the IPv4 Address associated with your active network adapter.</p><p>Q: Do you have any listen port number suggestion?<br>A:<br>Port 2222 can be used an example for SSH or other services, though you may select any available port number above 1024 and below 65535 to avoid conflicts with system and well-know ports.</p><p>Q: How to find my WSL Internal IP?<br>A:<br>1. Open your WSL terminal.<br>2. Run the command ip addr | grep eth0 .<br>3. Look for the network interface (usually eth0) and note the IP address following inet.</p><h3>Enabling Inbound Rules for SSH in Windows Firewall</h3><p>After setting up port forwarding, it will expose a service running on a private network to a public network. The Windows Firewall will protect its system and network by controlling inbound and outbound network traffic. So the Windows Fire wall is not configured to allow incoming connection on the port you’re forwarding.</p><p>Run the following command in PowerShell to enable Inbound Rules within the port:</p><pre>netsh advfirewall firewall add rule `<br>name=&quot;&lt;any_name&gt;&quot; `<br>dir=in `<br>action=allow `<br>protocol=TCP `<br>localport=&lt;listen_port_on_windows&gt;</pre><p>Explanation:<br>- name=WSL2 is the rule name. You can rename as needed.<br>- dir=in specifies the <strong>dir</strong>ection of the rule as <strong>in</strong>bound, meaning it allows connections from outside into the local machine.<br>- action=allow specifies the action for the connections that match this rule; here, it allows those connections.<br>- protocol=TCP specifies the protocol type that the rule applies to.<br>- localport=&lt;listen_port_on_windows&gt; specifies the local port number that the rule applies to.</p><h3>Set up Port Forwarding on Router (For WAN)</h3><p>Navigate to Port Forwarding settings in the router’s settings menu.</p><p>Configure the router to forward traffic from a specific external port on the public internet to a corresponding local destination port on your windows computer identified by its IP address.</p><p>The specific external port can be set to any value of your choice. The local destination port is &lt;listen_port_on_windows&gt; . The IP address of your Windows machine is &lt;windows_local_ip&gt; .</p><h3>Connecting to WSL via SSH</h3><h4>From Local Area Network (LAN)</h4><p>Run following command in the terminal on a different device within the LAN to verify connectivity:</p><pre>ssh &lt;wsl_username&gt;@&lt;windows_ip&gt; -p &lt;listen_port_on_windows&gt;</pre><p>You will see a successful content message after running the command, indicating that port forwarding has been set up successfully! 🥳🥳🥳</p><h4>From Wide Area Network (WAN)</h4><p>To connect to a device within a local network form a WAN, you my need to configure port forwarding on the router. The route services as the gateway between the internal an external networks.</p><p>Run the following SSH command in the terminal from a device on a different network to verify connectivity:</p><pre>ssh &lt;wsl_username&gt;@&lt;public_wan_ip&gt; -p &lt;external_ssh_port&gt;</pre><p>Explanation:<br>- &lt;public_wan_ip&gt;: The public WAN IP address of your network.<br>- &lt;external_ssh_port&gt;: The external port number designated for SSH in your router’s port forwarding settings.</p><h3>Summary</h3><p>The content above covered the steps and some explanations. Now let’s briefly go over all the action steps for quick guidance.</p><h4>Step 1: Reinstalling SSH on WSL 2</h4><p>Remove SSH:</p><pre>sudo apt remove openssh-server</pre><p>Install SSH:</p><pre>sudo apt install openssh-server</pre><h4>Step 2: Configuring SSH on WSL 2</h4><p>Edit SSH config:</p><pre>sudo vi /etc/ssh/sshd_config, enable Port 22 and PasswordAuthentication yes</pre><p>Restart SSH:</p><pre>sudo service ssh restart</pre><h4>Step 3: Configuring Port Forwarding on Windows</h4><p>Run in PowerShell:</p><pre>netsh interface portproxy add v4tov4 `<br>  listenaddress=192.168.100.1 `<br>  listenport=2222 `<br>  connectaddress=192.168.100.2 `<br>  connectport=22</pre><h4>Step 4: Enabling Inbound Rule on Windows Firewall</h4><p>Execute in PowerShell:</p><pre>netsh advfirewall firewall add rule `<br>dir=in `<br>protocol=TCP `<br>localport=2222<br>action=allow `</pre><h4>Step 5: Set up Port Forwarding on Router (For WAN)</h4><p>Navigate to Port Forwarding settings in the router’s configuration page.</p><p>Forward traffic from port 2220 to port 2222 on the IP address of your Windows machine, which is 192.168.100.1 .</p><h4>Step 6: Verifying SSH to WSL</h4><p>Verifying on a Local Area Network</p><pre>ssh wsl2username@192.168.100.2. -p 2222</pre><p>Verifying on a Wide Area Network</p><pre>ssh wsl2username@172.16.254.3 -p 2220</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=013955b2f421" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>