
Remote SSH.
π Remote SSH Guide
π οΈ Install OpenSSH
sudo apt-get update && sudo apt-get install -y openssh-server
sudo nano /etc/ssh/sshd_config
Edit the port according to you. Letβs say 8081
.
π Install Gsocket
curl -sSL https://gsocket.io/install.sh | bash
If needed, now go to the gsocket folder, then ./gsocket
and then make install
as guided.
π For Gsocket:
curl -sSL https://gsocket.io/install.sh | bash
cd gsocket
./install.sh
cd gsocket
make install
π₯οΈ On Server:
gsocket /usr/sbin/sshd -d
Then enter any {PASS_KEY}
.
π» On Client:
gsocket -s PASS_KEY ssh root@gsocket -p 8081
(You can use root
or any available user on the server.)
π Ngrok Installation
# Remove the old version of ngrok if available
rm -f ngrok
# Download the latest ngrok version (Linux)
curl -o ngrok.zip https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
# Unzip it
unzip ngrok.zip
# Give execute permissions to ngrok
chmod +x ngrok
π₯οΈ Install Code-Server
curl -fsSL https://code-server.dev/install.sh | sh
code-server --bind-addr 0.0.0.0:7860 --auth none
ngrok http 7860
π― One single command:
code-server --bind-addr 0.0.0.0:7860 --auth none & ngrok http 7860
π BONUS: Using Socat
Install socat
:
apt install socat -y
Transfer port within localhost:
socat TCP-LISTEN:2222,fork TCP:localhost:8081
(port transferred from 8081 to 2222.)
π Using Localtunnel
npm install -g localtunnel
lt --port 8081
(or any port 8082..etc)
It will give a URL like:
https://your-subdomain.loca.lt
To SSH using the URL (I think the url can be used for ssh to turn local ip [hostname -I] into public like.):
ssh username@your-subdomain.loca.lt -p 8081
(Not working in my test for now, but very useful for future use.)
π SSH Tunneling:
- For me, first run localtunnel βIt βport 8081β, then u will get a link, then u can replace it with local ip.
Set up a reverse SSH tunnel on SERVER: First, run Localtunnel:
lt --port 8081
Then use the generated link:
ssh -R 8081:localhost:8081 username@remote-server-ip
or
ssh -R 8081:localhost:8081 root@your-subdomain.loca.lt
Access from Client:
ssh -p 8081 username@remote-server-ip
(Change accordingly. Play around with it.. but do not waste time β.)
π Ngrok TCP Forwarding
ngrok tcp 8081
(May allow only one task at a time in Ngrok, or may require a paid plan for TCP forwarding.)
π©οΈ Cloudflared (Argo Tunnel)
Very simple, go as you click:
apt-get install wget
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
dpkg -i cloudflared-linux-amd64.deb
Check version:
cloudflared --version
Run tunnel:
cloudflared tunnel --url http://localhost:8081
π Full command to run Code-Server with Cloudflared:
code-server --bind-addr 0.0.0.0:7860 --auth none & cloudflared tunnel --url http://localhost:7860
πΉ Optional: Run in the Background
- If you want to keep cloudflared running in the background, use nohup:
nohup cloudflared tunnel --url http://localhost:8081 > cloudflared.log 2>&1 &
π MORE TO EXPLORE:
π οΈ BORE (GitHub)
Exposes local ports to a remote server, bypassing standard NAT connection firewalls.
cargo install bore-cli
bore local 8000 --to bore.pub
Or:
# On the server
bore server --secret my_secret_string
# On the client
bore local <LOCAL_PORT> --to <TO> --secret my_secret_string
π Other tools:
π Frequently Used Commands
apt-get update && apt-get install -y openssh-server
apt install curl -y
apt-get install build-essential -y
apt install libssl-dev -y
apt-get install git -y
apt install automake -y
apt install autoconf -y
apt install nano -y
apt install npm -y
apt install systemctl -y
apt install net-tools -y
curl -fsSL https://code-server.dev/install.sh | sh
apt install wget -y
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
dpkg -i cloudflared-linux-amd64.deb
π‘ Run after installation:
code-server --bind-addr 0.0.0.0:7860 --auth none & cloudflared tunnel --url http://localhost:7860
π Enjoy Secure Remote Access!