- 작성시간 : 2019/08/18 09:15
- 퍼머링크 : mcchae.egloos.com/11336835
- 덧글수 : 0
오래 전에 역터널 연결에 관하여 정리한 적이 있습니다.
이번에는 ESXi 서버에 우분투서버를 VM으로 기동시킨 상황에서 해당 VM의
역터널을 Supervisor로 지정하는 것을 살펴보겠습니다.
우선 역터널을 해 보는데 다음과 같이 시도해 봅니다.
toor 라는 사용자라고 가정하고, ~/.ssh/config 라는 파일로 다음의 내용을 넣습니다.
host router
HostName my.host.name
User toor
Port 23422
Compression yes
GatewayPorts yes
IdentityFile "/home/toor/.ssh/id_rsa"
ServerAliveInterval 100
ServerAliveCountMax 3
# Reverse Port Forwardings
RemoteForward 51322 localhost:22
RemoteForward 51445 192.168.1.252:445
RemoteForward 51443 192.168.1.254:443
RemoteForward 51902 192.168.1.254:902
위에서 RemoteForward 항목이 역 터널 내용입니다.
시험 삼아서
ssh -nNT router
명령으로 잘 접속되는지 확인해 봅니다.
잘 접속되면, supervisor 를 설치합니다.
sudo apt-get install supervisor
만약 위의 명령어가 안 먹으면,
cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic main universe
deb http://archive.ubuntu.com/ubuntu bionic-security main universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
/etc/apt/sources.list 파일 내용 중에, universe 가 빠진 경우가 있었으니,
해당 내용을 넣고,
sudo apt-get update
후 설치 가능했습니다.
이제 supervisor가 설치되었으므로,
/etc/supervisor/conf.d/ssh_rf.conf 라는 파일을 만들어,
[program:ssh_rf]
command=/usr/bin/ssh -F /home/toor/.ssh/config -nNT router -p 23422
autostart=true
autorestart=true
stderr_logfile=/var/log/ssh-rf.err.log
stdout_logfile=/var/log/ssh-rf.out.log
라고 넣어 주고,
sudo service supervisor restart
라고 하면 해당 ssh 역터널을 supervisor가 모니터링 하고 있다가,
혹시 해당 프로세스가 종료 되더라도 자동으로 재 연결해 줍니다.
어느 분께는 도움이 되셨기를 ..



덧글