关于frp-ssh部署
Pub-IP Server
# git clone https://github.com.cnpmjs.org/fatedier/frp
wget https://github.com/fatedier/frp/releases/download/v0.37.0/frp_0.37.0_linux_amd64.tar.gz
tar -xzvf frp_0.37.0_linux_amd64.tar.gz
cd frp_0.37.0_linux_amd64/
rm -rf frps.ini
echo "# frps.ini
[common]
bind_port = 7000
dashboard_port = 10000
dashboard_user = username
dashboard_pwd = pwd
vhost_http_port = 18080
vhost_https_port = 10443
" >> frps.ini
tmux
./frps -c ./frps.ini
Private Server
Install openssh-server
- add to /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
- Install
sudo apt-get update
sudo apt-get install openssh-server
Download frp:
wget https://github.com/fatedier/frp/releases/download/v0.37.0/frp_0.37.0_linux_amd64.tar.gz
# or wget https://github.com.cnpmjs.org/fatedier/frp/releases/download/v0.37.0/frp_0.37.0_linux_amd64.tar.gz
tar -xzvf frp_0.37.0_linux_amd64.tar.gz
cd frp_0.37.0_linux_amd64/
Update config file:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 10022
[code-server]
type = http
local_port = 8081
custom_domains = x.x.x.x # IP or Domain
Enable frpc.service
FRPPWD=YOUR_PATH
sudo echo "[Fusion]
Description=Frp Server Daemon
After=syslog.target network.target
Wants=network.target
[Service]
Type=simple
ExecStart=$FRPPWD/frpc -c $FRPPWD/frpc.ini
ExecStop=/usr/bin/killall frpc
RestartSec=1min
KillMode=control-group
Restart=always
[Install]
WantedBy=multi-user.target" >> /etc/systemd/frpc.service
sudo systemctl enable /etc/systemd/frpc.service
sudo systemctl start frpc.service
sudo systemctl status frpc.service
[Note: for restart]
sudo systemctl restart frpc.service
Usage
ssh -p 10022 ubuntu@xxxxx
Option: code-server
if [ ! -f ./vsc/code-server ]; then
wget https://github.com/cdr/code-server/releases/download/v3.12.0/code-server-3.12.0-linux-amd64.tar.gz -O vsc.tar.gz
mkdir ./vsc && tar -zxvf vsc.tar.gz -C ./vsc --strip-components 1
rm -rf vsc.tar.gz
fi
VSBASE=$(pwd)
IPADD=$(ifconfig | grep "inet " | grep "broadcast" | awk '{print $2}')
cd vsc
tmux kill-session -t $VSBASE
tmux new -s $VSBASE -d
for port in {8081..18081}
do
PORTCT=$(lsof -i -P -n | grep LISTEN | grep :$port | wc -l)
if [ $PORTCT = "0" ]; then
PORTUSE=$port
break
fi
done
tmux send -t $VSBASE "PASSWORD=123 ./code-server --host 0.0.0.0 --port $PORTUSE" Enter
echo http://$IPADD:$PORTUSE 2>&1 | tee ../url.log