efxtv

Docker Ubuntu Setup Guide with SSH Chat server (onion link) | labs.play-with-docker.com Darkweb

Jul 1st, 2025 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | Cybersecurity | 0 0
  1. # 🐳 Docker Ubuntu Setup Guide with SSH & Local Chat Server Access (Onion link) labs.play-with-docker.com
  2.  
  3. ####################################################################
  4. Join our telegram channel: https://t.me/LinuxClassesEFXTv
  5. ####################################################################
  6. Go to https://labs.play-with-docker.com/ or setup docker in local machine
  7. Paste the public keys we are going to generate in in local machine to the location ~/.ssh/authorized_keys
  8.  
  9. Generate ssh keys in local machine
  10. $ mkdir ~/sshserver
  11. $ cd sshserver
  12. $ ssh-keygen -t ed25519 (Enter the phrase 2 times)
  13.  
  14. # Paste the keys to the lab.play-with-docker.com in
  15. vi ~/.ssh/authorized_keys
  16.  
  17. # Connect to machine labs.play***
  18. chmod 600 keyname
  19. ssh -i ~/sshserver/keyname ********************.labs.play-with-docker.com
  20.  
  21. ####################################################################
  22.  
  23.  
  24. ## Step 1: Pull the Ubuntu Docker Image
  25. docker pull ubuntu
  26.  
  27. ####################################################################
  28. ## Step 2: Create and Start the Docker Container
  29. docker run -dit --name chatserver -p 2222:22 -p 8080:8080 ubuntu
  30.  
  31. #EXPLAIN:
  32. Syntax Part Explanation
  33. docker run This is the base Docker command to create and start a new container from an image.
  34. -d Detached mode — runs the container in the background. You won’t see its output directly.
  35. -i Interactive mode — keeps STDIN open for input, useful when working inside the container.
  36. -t TTY (terminal) — allocates a pseudo-terminal. Allows you to run shell/bash commands.
  37. --name sshbox Assigns a custom name to the container (sshbox in this case) for easier reference.
  38. -p 2222:22 Port mapping → Maps host port 2222 to container’s port 22 (commonly used by SSH).
  39. -p 8080:8080 Maps host port 8080 to container’s 8080 — useful for running a web server.
  40. ubuntu The base image to use here, we’re pulling and running the official Ubuntu image.
  41. ####################################################################
  42.  
  43. ## Step 3: Access the Container
  44. docker exec -it chatserver bash
  45.  
  46. EXPLAIN:
  47. docker exec Runs a command inside an already running container.
  48. -i Interactive mode — keeps STDIN open so you can type commands.
  49. -t TTY (pseudo-terminal) — gives you a usable terminal inside the container.
  50. sshbox The name of the container you want to connect to (as set earlier).
  51. bash The command you want to run inside the container — here it's bash shell.
  52. ####################################################################
  53.  
  54. ## Step 4: Set Up Inside the Container
  55. apt update && apt upgrade -y;apt install -y openssh-server python3-full curl wget php vim sudo unzip net-tools
  56.  
  57. sudo passwd root
  58.  
  59. ## Step 7: Enable SSH Login
  60. nano /etc/ssh/sshd_config
  61.  
  62. # Set the following:
  63. PermitRootLogin yes
  64. PasswordAuthentication yes
  65.  
  66. # Then restart SSH:
  67. mkdir -p /var/run/sshd
  68. service ssh restart
  69.  
  70. ## Step 9: Shared Directory
  71. mkdir -p /root/shared
  72.  
  73. # Try to connect to ssh in docker
  74. ssh root@localhost
  75.  
  76. ## Step 8: This detaches you from a Docker container’s terminal without stopping it.
  77. Ctrl + P then Ctrl + Q
  78.  
  79. # Try to connect outside the docker container
  80. ssh root@localhost
  81.  
  82. # Create and activate Python virtual environment
  83. python3 -m venv myenv
  84. source myenv/bin/activate
  85.  
  86. # Install pyngrok
  87. pip install pyngrok
  88. # ngrok config add-authtoken YOUR_AUTH_TOKEN
  89. ngrok config add-authtoken **************************************
  90.  
  91. # Start ngrok tcp 2222
  92. ngrok tcp 2222
  93.  
  94. # Then forward SCP: (join our telegram to get the file)
  95. scp -P PORT chat.zip root@IPADDRESS:/root/shared
  96.  
  97. # Close the tunnel once copied
  98. ctrl + c
  99.  
  100.  
  101. ####################################################################
  102. ## Step 6: Resume the docker container
  103. docker start -ai chatserver
  104.  
  105. EXPLAIN:
  106. Syntax Part Explanation
  107. docker start Starts a stopped container (does not create a new one).
  108. -a Attach — connects your terminal to the container’s STDOUT/STDERR output.
  109. -i Interactive mode — keeps STDIN open so you can interact with the container.
  110. sshbox The name of the container you want to start (defined earlier with --name).
  111. ####################################################################
  112.  
  113. ####################################################################
  114. ## Step 11: Start local werb server in background
  115. php -S 0.0.0.0:8080 > /dev/null 2>&1 &
  116.  
  117. EXPLAIN:
  118. php -S 0.0.0.0:8080 Starts PHP’s built-in server on all interfaces (0.0.0.0) and listens on port 8080. Useful for serving a local website or PHP app.
  119. > /dev/null Redirects standard output (stdout) to /dev/null, essentially hides normal output.
  120. 2>&1 Redirects standard error (stderr) to the same place as stdout — i.e., also hidden.
  121. & Runs the whole command in the background, so your terminal is free for other tasks.
  122. ####################################################################
  123.  
  124. ## Detaches from Docker container AGAIN
  125. Ctrl + P then Ctrl + Q
  126.  
  127. ## Step 12: Start http server
  128. ngrok http localhost:8080
  129.  
  130. ## Step 13: Reattach to Container (Optional)
  131. docker attach sshbox
  132.  
  133. ## Fix SSH WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
  134. # Error: Host key verification failed
  135.  
  136. # Solution:
  137. vi ~/.ssh/known_hosts
  138. # Delete line with: [localhost]:2222
  139.  
  140. # Retry SSH:
  141. ssh root@localhost -p 2222
  142.  
  143. ####################################################################
  144. ✅ Step-by-Step: Expose Your PHP Server via Tor
  145. 🛠️ 1. Install Tor
  146. On Ubuntu/Debian:
  147. sudo apt update
  148. sudo apt install tor
  149.  
  150. 📂 2. Edit Tor Configuration
  151. sudo vi /etc/tor/torrc
  152.  
  153. At the end, add the following lines:
  154. HiddenServiceDir /var/lib/tor/php_hidden_service/
  155. HiddenServicePort 80 127.0.0.1:8080
  156.  
  157. 🔄 3. Restart Tor
  158. sudo systemctl restart tor
  159.  
  160. 🧪 Example Combined Setup
  161. php -S 127.0.0.1:8080 > /dev/null 2>&1 &
  162.  
  163. ✅ Workaround: Start Tor Manually (Without systemd)
  164. tor &
  165.  
  166. ✅ Check Tor Output
  167. cat /var/lib/tor/php_hidden_service/hostname
  168.  
  169. ####################################################################
  170. Create onion link in termux
  171. ####################################################################
  172. # Set up a Tor-accessible PHP website on Termux
  173.  
  174. # Step 1: Update & install required packages
  175. pkg update && pkg upgrade -y
  176. pkg install tor php wget git -y
  177.  
  178. # Step 2: Create PHP site
  179. mkdir -p ~/website
  180. cat << 'EOF' > ~/website/index.php
  181. <?php
  182. echo "Hello, Dark Web!";
  183. ?>
  184. EOF
  185. # Get in to project root
  186. chmod -R 755 ~/website
  187. chmod -w index.php
  188. cd ~/website
  189.  
  190. # Start PHP server
  191. php -S 127.0.0.1:8080
  192.  
  193. or
  194.  
  195. php -S 127.0.0.1:8080 -t /sdcard/web
  196.  
  197. or
  198.  
  199. python3 -m http.server 8080
  200.  
  201. # Step 3: Configure Tor hidden service
  202. mkdir -p ~/.tor/hidden_service
  203. chmod 700 ~/.tor/hidden_service
  204.  
  205. cat << 'EOF' > ~/.torrc
  206. HiddenServiceDir /data/data/com.termux/files/home/.tor/hidden_service/
  207. HiddenServicePort 80 127.0.0.1:8080
  208. EOF
  209.  
  210. # Step 4: Start Tor service
  211. tor
  212.  
  213. # Step 5: Get the .onion link
  214. cat ~/.tor/hidden_service/hostname
  215.  
  216. # Done! Visit page
  217.  
Add Comment
Please, Sign In to add comment