๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Full-Stack ์„ ์œ„ํ•˜์—ฌ..

์„œ๋ฒ„์—์„œ(ssh) GUI ์‚ฌ์šฉํ•˜๊ธฐ (Window, MacOS) & ์„œ๋ฒ„ ๋‘ ๋ฒˆ ํƒ€๊ธฐ(ssh proxyjump)

by ์ž„๋ฆฌ๋‘ฅ์ ˆ 2024. 12. 10.
๋ฐ˜์‘ํ˜•

์„œ๋ฒ„๋กœ ์ด๊ฒƒ ์ €๊ฒƒ ์‹œ๊ฐํ™”ํ•˜๊ณ  ๋ฐ์ดํ„ฐ ๋„์šฐ๋‹ค๋ณด๋‹ˆ 

์•„๋ฟ”์‹ธ

๊ธฐ์กด local๋กœ ํ•˜๋˜ ๋•Œ๋ž‘์€ ๋‹ฌ๋ฆฌ ์•ˆ๋„์›Œ์ง€๋Š”๊ฑฐ๋‹ค..!

ํ•ญ์ƒ png๋‚˜ pdf๋กœ ์ €์žฅํ•˜๊ธฐ๋„ ๋ญํ•˜๊ณ ....... 

GUI ๋„์šฐ๋Š” ๋ฒ•์„ ์ฐพ์•„๋ดค๋‹ค. 

 

์ฐธ๊ณ ๋กœ ๋‚˜๋Š” window, mac ๋‘˜๋‹ค ์‚ฌ์šฉํ•ด์„œ ๋‘ ๋ฐฉ๋ฒ• ๋‹ค ์žˆ๋‹ค !@!!!@@

+ ์„œ๋ฒ„ ๋‘๋ฒˆ ํฌํŠธํฌ์›Œ๋”ฉ ๋ฐฉ๋ฒ•๋„ ํฌํ•จ๋˜์–ด ์žˆ๋‹ค. 


in Mac

XQuartz ์„ค์น˜

https://www.xquartz.org/index.html

 

XQuartz

The XQuartz project is an open-source effort to develop a version of the X.Org X Window System that runs on macOS. Together with supporting libraries and applications, it forms the X11.app that Apple shipped with OS X versions 10.5 through 10.7. Quick Down

www.xquartz.org

๋˜๋Š” mac์—์„œ brew๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด 

brew install --cask xquartz

๋ฅผ ์„ค์น˜ํ•˜๊ณ  ๊ป๋‹ค ํ‚ค๊ธฐ

 

  • set x11 preferences

Xquartz๋ฅผ ์ผœ์„œ ํ™˜๊ฒฝ์„ค์ • ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ•ด์ฃผ์ž.

local์—์„œ 

xeyes ๋กœ ํ™•์ธ

ํ˜น์€

xclocks

์„œ๋ฒ„์—์„œ 

echo $DISPLAY

๋กœ ๋””์Šคํ”Œ๋ ˆ์ด local host ์žกํžˆ๋Š” ์ง€๋„ ํ™•์ธํ•˜๋ฉด ok !

Setting GUI in SSH & Proxyjump

  • ์ถ”๊ฐ€๋กœ ๋‚˜๋Š” SSH์—์„œ ์„œ๋ฒ„๋ฅผ ๋‘ ๋ฒˆ ํƒ€๊ณ  ๋“ค์–ด๊ฐ€๋Š” ์ƒํ™ฉ์œผ๋กœ ๋ฐ”๋€Œ์–ด์„œ Forward๋ฅผ ๋‘๋ฒˆ ํ•ด์ค˜์•ผ ํ–ˆ๋‹ค.
# Step 1: Connect to the 1 server first
Host {first}
  HostName {IPaddress}
  User Username
  Port 22
  ForwardAgent yes		# ์ถ”๊ฐ€ํ•œ ๋ถ€๋ถ„	
  ForwardX11 yes        # ์ถ”๊ฐ€ํ•œ ๋ถ€๋ถ„
  ForwardX11Trusted yes # ์‹ ๋ขฐ๋œ X11 ํฌ์›Œ๋”ฉ ํ™œ์„ฑํ™”
  LocalForward 22 {secondIPaddress}:22

# Step 2: Connect to the 2 server through tyweb
Host {second}
  HostName {secondIPaddress}
  User ish
  Port 22
  ProxyJump {first}
  ForwardAgent yes
  ForwardX11 yes
  ForwardX11Trusted yes
  • ํ—ท๊ฐˆ๋ฆฌ์ง€ ์•Š๊ฒŒ first์™€ second๋ฅผ ์ž˜ ํ™•์ธํ•ด์•ผํ•œ๋‹ค. 
  • ์ฐธ๊ณ ๋กœ VScode์—์„œ second ์—ฐ๊ฒฐ ๋ˆ„๋ฅด๋ฉด ์•Œ์•„์„œ
    first ํƒ”๋‹ค๊ฐ€ -> second ๋Œ์•„์˜ค๋Š” ๊ฒƒ์ด๋‹ค ! (proxyjump)

 

  • ๊ทธ๋ฆฌ๊ณ  ํ•˜๋ฉด์„œ ๊ณ„์† display ์ฐํžˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ 

ํ™•์ธ ์˜ˆ์‹œ

์ฐธ๊ณ  : https://www.cyberciti.biz/faq/apple-osx-mountain-lion-mavericks-install-xquartz-server/ 

 

โ€‹

์ถ”๊ฐ€๋กœ ERROR 1 : X11์ด ์ž˜ ์•ˆ๋œ๋‹ค ? 

  • ์ตœ๊ทผ ๋ฒ„์ „์˜ homebrew๋Š” ImageMagick--with-X11 ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜์—ฌ X11์— ๋Œ€ํ•œ ์ง€์›์„ ์ค‘๋‹จํ–ˆ๋‹ค๊ณ  ํ•จ
  • ๋ฌธ์ œ ๋ถ„์„
    1. xhost +๊ฐ€ ๋กœ์ปฌ์—์„œ ์ •์ƒ ์ž‘๋™ํ•˜์ง€ ์•Š์Œ: ์ด๋Š” X11 ์„œ๋ฒ„์—์„œ ์ ‘๊ทผ ์ œ์–ด๊ฐ€ ์ œ๋Œ€๋กœ ์„ค์ •๋˜์—ˆ๋Š”๊ฐ€?
    2. X11 ํฌ์›Œ๋”ฉ ์„ค์ •: SSH ์„ธ์…˜์—์„œ X11 ํฌ์›Œ๋”ฉ์ด ํ™œ์„ฑํ™”๋˜์ง€ ์•Š์•˜๊ฑฐ๋‚˜, X ์„œ๋ฒ„๊ฐ€ ์ œ๋Œ€๋กœ ์—ฐ๊ฒฐ๋˜์ง€ ์•Š์•˜์„ ๊ฐ€๋Šฅ์„ฑ?
    #in local 
    ps aux | grep X11 #x11์‹คํ–‰์ค‘์ธ์ง€ ํ™•์ธ 
    /Applications/Utilities/XQuartz.app/Contents/MacOS/X11.bin
    /opt/X11/bin/quartz-wm
    /opt/X11/bin/Xquartz :0 -listen tcp +iglx +extension GLX
#in server
echo $DISPLAY                                                 
localhost:11.0             # ํ•ด์„œ ๋‚ด ๋กœ์ปฌํ˜ธ์ŠคํŠธ ํ™•์ธํ•œ ํ›„์— 

echo 'export DISPLAY=localhost:11.0' >> ~/.zshrc                  
# ํ™˜๊ฒฝ ๋ณ€์ˆ˜ zshrc์— ์ถ”๊ฐ€ ํ•ด์ฃผ๊ณ  
# ๊ทผ๋ฐ ๊ฐ€๋” ๋ฐ”๋€๋‹ค. ์ด๊ฒƒ์€ ๊ทธ๋ƒฅ ๊ฐ€๋” hoxy..? ํ•  ๋•Œ ํ™•์ธํ•˜๊ณ  ๋‹ค์‹œ ๋ณ€์ˆ˜ ์ ์šฉํ•ด์ฃผ๋ฉด ๋œ๋‹ค. 

source ~/.zshrc            # ๋ณ€๊ฒฝ ์ ์šฉ.   
# localhost ๊ฐ€ ํ™•์ธํ•˜๋‹ˆ ๋‹ค์‹œ ๋ฐ”๋€Œ์–ด์„œ ์•ˆ์žกํ˜”์—ˆ๋Š”๋ฐ 
# ๊ทธ๋ƒฅ.. ์ฐจ๊ทผ์ฐจ๊ทผ ๋‹ค์‹œํ•˜๊ณ  ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์ ์šฉ๋ฐ ๋ฆฌ๋กœ๋”ฉํ•˜๋‹ˆ ๋ญ.. ๋๋‹ค..

#์ถ”๊ฐ€๋กœ ํ•„์š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ 
conda install -c conda-forge xorg-libx11 xorg-libxext xorg-libxi xorg-libsm xorg-libice
#conda install -c conda-forge xorg-xeyes  #์•ˆ๋˜๋ฉด
#conda install -c conda-forge xorg-xauth xorg-xrandr

์ฃผ์„์œผ๋กœ ์จ๋†“์•˜๋“ฏ์ด, ๊ฐ€๋” localhost ๋ฐ”๋€Œ๋‹ˆ๊นŒ ์•ˆ๋œ๋‹ค ์‹ถ์œผ๋ฉด ํ™•์ธํ•˜๊ณ  ๋ฐ”๊ฟ”์ฃผ์ž !

 

 

์ถ”๊ฐ€๋กœ ERROR 2 : X11์—ฐ๊ฒฐ ๋ฌธ์ œ? 

  • xhost + <serverip> (nslookup์„ ์‚ฌ์šฉํ•˜๋ฉด ip๋ฅผ ์•Œ์ˆ˜์žˆ๋‹ค)
  • xhost + ๋ฅผ ํ•ด์„œ ๋ชจ๋‘๊ฐ€ ๋“ค์–ด์˜ฌ ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” (access control disabled)
xhost +
#access control disabled, clients can connect from any host

xhost + {firstIPaddress}
xhost + {secondIPaddress}

#{firstIPaddress} being added to access control list
#{secondIPaddress} being added to access control list
  • ํ˜น์‹œ ๋ชจ๋ฅด๋‹ˆ ์„œ๋ฒ„๋„ ํ™•์ธํ•ด๋ณด๋‹ˆ ... 

์„œ๋ฒ„๋‚ด ssh/sshd_config ํ™•์ธํ•ด๋ณด๋‹ˆ ์„œ๋ฒ„๋Š” x11forwarding์ด ํ™œ์„ฑํ™” ๋˜์–ด์žˆ๋‹ค. (์ด๊ฒƒ๋„ ํ•„์ˆ˜ ์ž‘์—…์ž„)

 

๋‹ค์‹œ ์ง€์šฐ๊ณ  ๊น”๊ณ  Xquartz ๊ฐ•์ œ ์„ค์ •ํ•˜๋Š” ์ปค๋งจ๋“œ ์ •๋ฆฌ (์ตœ์ข…๋ณ‘๊ธฐ ๋˜๊ฒ ๋‹ค)

pkill XQuartz
open -a XQuartz
export DISPLAY=localhost:10.0
xhost +
ps aux | grep XQuartz
tail -f /private/var/log/system.log | grep XQuartz

in window

์ฐธ๊ณ  : 

https://velog.io/@pikamon/Linux-1

 

[Linux] SSH๋กœ GUI ์‹คํ–‰ํ•˜๊ธฐ (X11, PuTTY)

์œˆ๋„์šฐ์—์„œ ssh๋ฅผ ํ†ตํ•ด ์šฐ๋ถ„ํˆฌ์— ์ ‘์†ํ•œ ํ›„ GUI ๊ฒฐ๊ณผ๋ฅผ ์œˆ๋„์šฐ๋กœ ๊ฐ€์ ธ์™€์„œ ๋ณด๊ณ ์‹ถ์„ ๋•Œ๊ฐ€ ์žˆ๋‹ค.์•„๋ž˜ ์‚ฌ์ดํŠธ์—์„œ Xming์„ ๋‹ค์šด๋ฐ›์•„์„œ ์„ค์น˜ํ•œ๋‹ค.https://sourceforge.net/projects/xming/์„ค์น˜ ํŒŒ์ผ ์‹คํ–‰ํ•˜๊ณ  ๋ƒ…

velog.io

 

  • ubuntu ssh ์„ค์ •
    • etc/ssh/sshd_config ์—ด์–ด์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์ •.
    • ํ•˜๋Š”๋ฐ permission denied ๋– ์„œ ๊ทธ๋ƒฅ ssh_config ํŒŒ์ผ ์–ต์ง€๋กœ ์ฐพ์•„์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์ •ํ•ด์คฌ๋‹ค

์œˆ๋„์šฐ๋Š” ์ด๋ ‡๊ฒŒ๋งŒํ•ด๋„ ์•Œ์•„์„œ ์ž˜ ๋œ๋‹ค... 

์•„ ! ์œˆ๋„์šฐ๋„ ์œˆ๋„์šด๋ฐ WSL **** ์ด ๊ทธ๋ƒฅ ์ž˜๋œ๋‹ค 

๋ฐ˜์‘ํ˜•

์ตœ๊ทผ๋Œ“๊ธ€

์ตœ๊ทผ๊ธ€

skin by ยฉ 2024 ttutta