이런저런 에러를 내면서 못도는거

home/minimonk/.local/lib/python3.10/site-packages/torch/cuda/__init__.py:384: UserWarning: Found GPU0 NVIDIA GeForce GTX 1080 Ti which is of compute capability (CC) 6.1.
The following list shows the CCs this version of PyTorch was built for and the hardware CCs it supports:
- 7.5 which supports hardware CC >=7.5,<8.0
- 8.0 which supports hardware CC >=8.0,<9.0 except {8.7}
- 8.6 which supports hardware CC >=8.6,<9.0 except {8.7}
- 9.0 which supports hardware CC >=9.0,<10.0
- 10.0 which supports hardware CC >=10.0,<11.0 except {10.1}
- 12.0 which supports hardware CC >=12.0,<13.0
Please follow the instructions at https://pytorch.org/get-started/locally/ to install a PyTorch release that supports one of these CUDA versions: 12.6
  _warn_unsupported_code(d, device_cc, code_ccs)
/home/minimonk/.local/lib/python3.10/site-packages/torch/cuda/__init__.py:384: UserWarning: Found GPU1 NVIDIA GeForce GTX 1080 Ti which is of compute capability (CC) 6.1.
The following list shows the CCs this version of PyTorch was built for and the hardware CCs it supports:
- 7.5 which supports hardware CC >=7.5,<8.0
- 8.0 which supports hardware CC >=8.0,<9.0 except {8.7}
- 8.6 which supports hardware CC >=8.6,<9.0 except {8.7}
- 9.0 which supports hardware CC >=9.0,<10.0
- 10.0 which supports hardware CC >=10.0,<11.0 except {10.1}
- 12.0 which supports hardware CC >=12.0,<13.0
Please follow the instructions at https://pytorch.org/get-started/locally/ to install a PyTorch release that supports one of these CUDA versions: 12.6
  _warn_unsupported_code(d, device_cc, code_ccs)
/home/minimonk/.local/lib/python3.10/site-packages/torch/cuda/__init__.py:502: UserWarning: 
NVIDIA GeForce GTX 1080 Ti with CUDA capability sm_61 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_75 sm_80 sm_86 sm_90 sm_100 sm_120.
If you want to use the NVIDIA GeForce GTX 1080 Ti GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/

 

torch.AcceleratorError: CUDA error: no kernel image is available for execution on the device
Search for `cudaErrorNoKernelImageForDevice' in https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html for more information.
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

 

cu118로 낮추니 잘된다. 만세!

pip3 uninstall -y torch triton
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

 

 

.이거면.. openai 쪽 api도 필요없고

허깅페이스에서 모델만 받으면 어떻게 해결 될 듯 한데

그래도 KURE-v1이 가볍단 해도 아주 가벼운건 또 아니네..

python3                                2354MiB

 

일단은 잘 돌아가는 것 같은니. pgvector랑 연동해보자 ㅋㅋ

>>> from sentence_transformers import SentenceTransformer
>>> from sklearn.metrics.pairwise import cosine_similarity
>>> 
>>> model = SentenceTransformer("nlpai-lab/KURE-v1")
Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.
Loading weights: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 391/391 [00:00<00:00, 1080.33it/s]
>>> 
>>> documents = [
...     "고양이가 소파 위에 앉아 있다.",
...     "강아지가 공원에서 뛰어논다.",
...     "반려동물이 집에서 쉬고 있다."
... ]
>>> 
>>> query = "집 안의 동물"
>>> 
>>> doc_embeddings = model.encode(
...     documents,
...     normalize_embeddings=True
... )
>>> 
>>> query_embedding = model.encode(
...     query,
...     normalize_embeddings=True
... )
>>> 
>>> scores = cosine_similarity(
...     [query_embedding],
...     doc_embeddings
... )[0]
>>> 
>>> for doc, score in zip(documents, scores):
...     print(f"{score:.4f} : {doc}")
... 
0.6314 : 고양이가 소파 위에 앉아 있다.
0.6035 : 강아지가 공원에서 뛰어논다.
0.7798 : 반려동물이 집에서 쉬고 있다.

 

혹시나 해서 찾아본 cuda 1 번으로 돌리는 방법

sentence_transformer
nlpai-lab/KURE-v1


from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity

model = SentenceTransformer("nlpai-lab/KURE-v1", device="cuda:1")

documents = [
    "고양이가 소파 위에 앉아 있다.",
    "강아지가 공원에서 뛰어논다.",
    "반려동물이 집에서 쉬고 있다."
]

query = "집 안의 동물"

doc_embeddings = model.encode(
    documents,
    normalize_embeddings=True
)

query_embedding = model.encode(
    query,
    normalize_embeddings=True
)

scores = cosine_similarity(
    [query_embedding],
    doc_embeddings
)[0]

for doc, score in zip(documents, scores):
    print(f"{score:.4f} : {doc}")

 

좋아좋아 gpu 1번 ㅋㅋ

'프로그램 사용 > ai 프로그램' 카테고리의 다른 글

openai api  (0) 2026.05.18
RAG 시도 - postgresql(14) + pgvector  (1) 2026.05.15
wan2.2  (0) 2026.05.13
openwebui 설치 시도  (0) 2026.05.13
LLM 소비전력 단상  (2) 2026.05.13
Posted by 구차니

 

[링크 : https://github.com/PINTO0309/TensorflowLite-UNet]

[링크 : https://huggingface.co/qualcomm/Unet-Segmentation]

[링크 : https://github.com/milesial/Pytorch-UNet]

[링크 : https://github.com/Rumit95/Auto_Segmentation] semantic segmentation

[링크 : https://github.com/Rumit95/Semantic-Segmentation-of-Image]

 

 

  • 클래스 1: 애완 동물에 속하는 픽셀
  • 클래스 2: 애완동물과 접하는 픽셀
  • 클래스 3: 위에 속하지 않음/주변 픽셀

[링크 : https://www.tensorflow.org/tutorials/images/segmentation?hl=ko]

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

MVTec AD 데이터 셋  (0) 2026.05.20
VAD - PaDiM, Patchcore - 정상이 아님을 탐지  (0) 2026.05.19
QAT, PTQ .. 모델 경량화  (0) 2026.05.14
unet  (0) 2026.05.06
keras - transfer learning / fine tuning  (0) 2025.09.17
Posted by 구차니

QAT - Quantization Aware Training

양자화 하지 않고 학습후

# Load MNIST dataset
mnist = keras.datasets.mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

# Normalize the input image so that each pixel value is between 0 to 1.
train_images = train_images / 255.0
test_images = test_images / 255.0

# Define the model architecture.
model = keras.Sequential([
  keras.layers.InputLayer(input_shape=(28, 28)),
  keras.layers.Reshape(target_shape=(28, 28, 1)),
  keras.layers.Conv2D(filters=12, kernel_size=(3, 3), activation='relu'),
  keras.layers.MaxPooling2D(pool_size=(2, 2)),
  keras.layers.Flatten(),
  keras.layers.Dense(10)
])

# Train the digit classification model
model.compile(optimizer='adam',
              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
              metrics=['accuracy'])

model.fit(
  train_images,
  train_labels,
  epochs=1,
  validation_split=0.1,
)

 

양자화 모델로 변환하고, 파인튜닝

import tensorflow_model_optimization as tfmot

quantize_model = tfmot.quantization.keras.quantize_model

# q_aware stands for for quantization aware.
q_aware_model = quantize_model(model)

# `quantize_model` requires a recompile.
q_aware_model.compile(optimizer='adam',
              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
              metrics=['accuracy'])

q_aware_model.summary()

train_images_subset = train_images[0:1000] # out of 60000
train_labels_subset = train_labels[0:1000]

q_aware_model.fit(train_images_subset, train_labels_subset,
                  batch_size=500, epochs=1, validation_split=0.1)

[링크 : https://www.tensorflow.org/model_optimization/guide/quantization/training?hl=ko]

 

PTQ - Post Training Quantization

[링크 : https://www.tensorflow.org/model_optimization/guide/quantization/post_training?hl=ko]

 

pruning - 0에 가까운 애들 없애기 (가지치기)

quantization (양자화)

distillation (증류)

low rank factorization (NxM -> Xxk kxM)

[링크 : https://u-b-h.tistory.com/13]

[링크 : https://asidefine.tistory.com/318]

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

VAD - PaDiM, Patchcore - 정상이 아님을 탐지  (0) 2026.05.19
U-net, segmentation  (0) 2026.05.14
unet  (0) 2026.05.06
keras - transfer learning / fine tuning  (0) 2025.09.17
keras ssd mobilenet  (0) 2025.09.16
Posted by 구차니

comfyui 보다가 동영상 만드는거에서 보이는 wan2.2 라는 키워드

이것도 알리바바 쪽 꺼라서 로고가 qwen이랑 같군.

[링크 : https://github.com/Wan-Video/Wan2.2]

[링크 : https://www.youtube.com/watch?v=sGZk2StxHho]

 

teacache 쓰면 빨리진다고 하는데..

[링크 : https://www.internetmap.kr/entry/TeaCache-with-Flux-GGUF-and-HunyuanVideo]

    [링크 : https://www.reddit.com/r/StableDiffusion/comments/1jllera/anyone_know_how_to_run_wan_21_on_a_gtx_1080ti/?tl=ko]

 

근데.. 파스칼은 안보이고 볼타부터 보이네.. 흐규흐규

[링크 : https://github.com/komikndr/raylight]

[링크 : https://github.com/pollockjj/ComfyUI-MultiGPU]

[링크 : https://github.com/robertvoy/ComfyUI-Distributed]

[링크 : https://github.com/Comfy-Org/ComfyUI/pull/7063]

    [링크 : https://www.reddit.com/r/comfyui/comments/1opv1t1/multi_gpu_support_for_video_generation_with_wan_22/]

Posted by 구차니

음.. 장렬히 실패 ㅋㅋ

[링크 : https://blog.oriang.net/69]

 

응 안 돼 돌아가~ 구글 ai 답변으로는 파이썬 3.11이 필요하다고

$ pip3 install open-webui
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement open-webui (from versions: none)
ERROR: No matching distribution found for open-webui

$ python3 --version
Python 3.10.12

[링크 : https://docs.openwebui.com/getting-started/quick-start/]

    [링크 : https://docs.openwebui.com/getting-started/]

 

귀찮으니 docker로 하는데 실행된다고 바로 접속되는게 아니라 좀 기다려야 하네

좌측 하단에 계정 눌러서 Settings 들어가고

 

좌측 하단에 작게 Admin Settings.. 어우 -_-

아무튼 Admin 설정으로 가야지 api 연결할 수 있다.

 

관리자 메뉴에서 connections 가면 이제 api 들이 보이는데

 

http://localhost:8080/v1 해도 되고. 아무튼 로컬에서는 llama-swap 으로 돌리는 중

 

api.openai.com은 일단 끄고 save

 

그러니까 llama-swap에서 설정된 모델들이 쭈욱 끌려나온다.

Areana model 하면 여러개 모델 싸워보게 하나본데 메모리 부족하니 일단 패스

 

위에서 인텔의 역사 인터넷 검색하라는데 그건 안된다고 하고

자기가 가진 정보로 답변하고 나서 다른거 하다가 뒤늦게(!) follow up 이라는게 뜬다. 왜 gpu가 계속 먹고 있나 했네..

 

클릭하면 바로 질문으로 넘어간다.

 

google PSE(programmable Search Engine)을 사용하면 인터넷 검색이 가능하다고 한다. 기본값으로는 안되겠군.

[링크 : https://wikidocs.net/307842]

 

 

+

대화창에 직접 url을 때려 넣으면 되는것 같기도 한데

 

주소를 직접 넣어주고

 

먼가 끌어오길 기다리면

 

저렇게 text로 들어간다. 음.. 이걸 웹 검색이라고 해줘야 하나 말아야 하나..

 

31 초 보다는 한참 더 오래 걸린거 같은디..

그 와중에 아까 했던 다음 검색 링크는 왜 들어가이는거냐 -_-

'프로그램 사용 > ai 프로그램' 카테고리의 다른 글

gpt님 만세! - pip torch 버전 낮추기  (0) 2026.05.15
wan2.2  (0) 2026.05.13
LLM 소비전력 단상  (2) 2026.05.13
rag 관련 라이브러리, 방법 조사중  (0) 2026.05.12
stable diffusion 모델 변경(SD -> SDXL)  (0) 2026.05.12
Posted by 구차니

음.. 메모리 사용량과 최대 소비전력을 곱하니 지금 드시는 소비전력이랑 얼추 비슷하게 나오는 느낌.

Stable Diffusion은 먹는 메모리 대비로는 많이 GPU를 굴릴수 있는데 (250W 를 가끔 초과하거나 근접하게 돌림)

사용중인 모델은 gemma4-e4b 이긴 한데  어떻게 저렇게 우연이라도 얼추 맞게 나오지?

 

Posted by 구차니

DB : postgres, VectorDB : pgvector

embedding

[링크 : https://github.com/gulcin/pgvector-rag-app]

    [링크 : https://edbkorea.com/blog/postgres-및-pgvector가-포함된-rag-앱/]

import PyPDF2
import torch
from transformers import pipeline

def generate_embeddings(tokenizer, model, device, text):
    inputs = tokenizer(
        text, return_tensors="pt", truncation=True, max_length=512
    ).to(device)
    with torch.no_grad():
        outputs = model(**inputs, output_hidden_states=True)
    return text, outputs.hidden_states[-1].mean(dim=1).tolist()


def read_pdf_file(pdf_path):
    pdf_document = PyPDF2.PdfReader(pdf_path)

    lines = []
    for page_number in  range(len(pdf_document.pages)):
        page = pdf_document.pages[page_number]

        text = page.extract_text()

        lines.extend(text.splitlines())

    return lines

[링크 : https://github.com/gulcin/pgvector-rag-app/blob/master/embedding.py]

[링크 : https://github.com/gulcin/pgvector-rag-app/blob/master/commands/import_data.py]

 

langchain, kure(임베딩 벡터 생성)

fast api, streamlit

[링크 : https://lsjsj92.tistory.com/686]

     [링크 : https://huggingface.co/nlpai-lab/KURE-v1]

 

ChromaDB, langchain

DB : postgres, VectorDB : pgvector

[링크 : https://velog.io/@judy_choi/PGVector-와-프롬프트를-이용한-RAG-고도화]

Posted by 구차니

antigravity 가라사대~

512x 512에서 1024x1024로 바꾸란다.

왜 되지?!?!

1. 해상도 (Resolution) 변경 🌟 (가장 중요)
SD 1.5는 기본적으로 512x512 해상도로 학습되었습니다.
SDXL은 1024x1024 기반으로 학습되었습니다. SDXL에서 512x512로 생성하면 이미지가 깨지거나 노이즈 덩어리처럼 나오게 됩니다.
변경: width와 height를 1024로 변경하거나, 원하는 비율에 맞춰 SDXL 권장 해상도(예: 832x1216, 1152x896 등)로 변경해야 합니다.
2. CFG Scale (분류기 자유도) 하향
현재 코드에 설정된 cfg_scale: 15 (img2img는 30)는 SD 1.5에서도 꽤 높은 편이지만, SDXL에서는 너무 높은 수치입니다. CFG가 너무 높으면 색감이 타고 이미지가 일그러집니다.
변경: SDXL은 프롬프트 이해력이 뛰어나므로 cfg_scale을 5.0 ~ 7.0 사이로 낮추는 것이 좋습니다.
3. 네거티브 프롬프트 (선택 사항)
SDXL (특히 파생 모델들)은 SD 1.5만큼 복잡하고 긴 네거티브 프롬프트나 Embedding(EasyNegative 등)에 크게 의존하지 않습니다. 오히려 너무 무거운 네거티브 프롬프트는 생성을 방해할 수 있습니다.
현재 코드에 있는 base_neg 정도면 나쁘지 않으나, 필요하다면 줄일 수 있습니다. (우선은 그대로 두셔도 무방합니다.)

 

512x512 생성 실패, VAE automatic 설정

 

1024x1024 생성 성공, VAE automatic 설정

 

 

----

API  •  GitHub  •  Gradio  •  Startup profile  •  Reload UI
version: v1.10.1-96-g1937682a  •  python: 3.10.12  •  torch: 2.1.2+cu121  •  xformers: N/A  •  gradio: 3.41.2  •  checkpoint: 6ce0161689

 

[링크 : https://civitai.com/models/795765/illustrious-xl]

[링크 : https://huggingface.co/OnomaAIResearch/Illustrious-xl-early-release-v0/tree/main]

 

illustriousXL 모델로 하면 이상하게 나오는데

 

처음에 해봤던 V1.5 emanoly는 정상적으로 잘 나온다.(물론 이상한 비행기 형태인건 여전하지만)

 

 

There's not much to it. The SDXL models work similar to other models. They are just more resource intensive.
Update your A1111 installation. I find it easiest to just run "git pull" from a command line.
Then download an SDXL model and VAE and put them with your other SD models. (The official SDXL release consists of a base model and a refiner but most people don't seem to bother with refiners.)
If your graphics card has less than 12 GB VRAM, then add the "--medvram-sdxl" argument.
Don't expect your 1.5 prompts to perform well with SDXL. You'll need to relearn how to write good prompts. Go to Civitai, grab a model that you like, look at the example images and study their prompts and settings. SDXL works best at around 1024×1024 pixels.

[링크 : https://www.reddit.com/r/StableDiffusion/comments/1bwidjg/updated_guide_on_how_to_run_sdxl_on_a1111/]

[링크 : https://huggingface.co/stabilityai/sdxl-vae]

 

/mnt/Downloads/stable-diffusion-webui/models$ ls -alR VAE*
VAE:
total 8
drwxrwxr-x  2 falinux falinux 4096  5월  4 21:38  .
drwxrwxr-x 11 falinux falinux 4096  5월  4 21:51  ..
-rw-rw-r--  1 falinux falinux    0  5월  4 21:38 'Put VAE here.txt'

VAE-approx:
total 432
drwxrwxr-x  2 falinux falinux   4096  5월  6 21:57 .
drwxrwxr-x 11 falinux falinux   4096  5월  4 21:51 ..
-rw-rw-r--  1 falinux falinux 213777  5월  4 21:38 model.pt
-rw-rw-r--  1 falinux falinux 213777  5월  6 21:57 vaeapprox-sdxl.pt

 

$ cat /mnt/Downloads/stable-diffusion-webui/repositories/generative-models/configs/inference/sd_xl_base.yamlml
model:
  target: sgm.models.diffusion.DiffusionEngine
  params:
    scale_factor: 0.13025
    disable_first_stage_autocast: True

    denoiser_config:
      target: sgm.modules.diffusionmodules.denoiser.DiscreteDenoiser
      params:
        num_idx: 1000

        weighting_config:
          target: sgm.modules.diffusionmodules.denoiser_weighting.EpsWeighting
        scaling_config:
          target: sgm.modules.diffusionmodules.denoiser_scaling.EpsScaling
        discretization_config:
          target: sgm.modules.diffusionmodules.discretizer.LegacyDDPMDiscretization

    network_config:
      target: sgm.modules.diffusionmodules.openaimodel.UNetModel
      params:
        adm_in_channels: 2816
        num_classes: sequential
        use_checkpoint: True
        in_channels: 4
        out_channels: 4
        model_channels: 320
        attention_resolutions: [4, 2]
        num_res_blocks: 2
        channel_mult: [1, 2, 4]
        num_head_channels: 64
        use_spatial_transformer: True
        use_linear_in_transformer: True
        transformer_depth: [1, 2, 10]  # note: the first is unused (due to attn_res starting at 2) 32, 16, 8 --> 64, 32, 16
        context_dim: 2048
        spatial_transformer_attn_type: softmax-xformers
        legacy: False

    conditioner_config:
      target: sgm.modules.GeneralConditioner
      params:
        emb_models:
          # crossattn cond
          - is_trainable: False
            input_key: txt
            target: sgm.modules.encoders.modules.FrozenCLIPEmbedder
            params:
              layer: hidden
              layer_idx: 11
          # crossattn and vector cond
          - is_trainable: False
            input_key: txt
            target: sgm.modules.encoders.modules.FrozenOpenCLIPEmbedder2
            params:
              arch: ViT-bigG-14
              version: laion2b_s39b_b160k
              freeze: True
              layer: penultimate
              always_return_pooled: True
              legacy: False
          # vector cond
          - is_trainable: False
            input_key: original_size_as_tuple
            target: sgm.modules.encoders.modules.ConcatTimestepEmbedderND
            params:
              outdim: 256  # multiplied by two
          # vector cond
          - is_trainable: False
            input_key: crop_coords_top_left
            target: sgm.modules.encoders.modules.ConcatTimestepEmbedderND
            params:
              outdim: 256  # multiplied by two
          # vector cond
          - is_trainable: False
            input_key: target_size_as_tuple
            target: sgm.modules.encoders.modules.ConcatTimestepEmbedderND
            params:
              outdim: 256  # multiplied by two

    first_stage_config:
      target: sgm.models.autoencoder.AutoencoderKLInferenceWrapper
      params:
        embed_dim: 4
        monitor: val/rec_loss
        ddconfig:
          attn_type: vanilla-xformers
          double_z: true
          z_channels: 4
          resolution: 256
          in_channels: 3
          out_ch: 3
          ch: 128
          ch_mult: [1, 2, 4, 4]
          num_res_blocks: 2
          attn_resolutions: []
          dropout: 0.0
        lossconfig:
          target: torch.nn.Identity

 

SD VAE 에서 refresh 하고

sdxl_vae.safetensors 를 선택하고 apply settings 해준 후

 

그리기 시도하니 얼추 비슷... 한건가?

 

원래는 이런 이미지

Hatsune Miku,limited palette,black background,colorful,vibrant,glowing outline,neon,blacklight,looking at viewer, masterpiece, very aesthetic Negative prompt: worst quality,bad quality,bad hands,very displeasing,extra digit,fewer digits,jpeg artifacts,signature,username,reference,mutated,lineup,manga,comic,disembodied,futanari,yaoi,dickgirl,turnaround,2koma,4koma,monster,cropped,amputee,text,bad foreshortening,what,guro,logo,bad anatomy,bad perspective,bad proportions,artistic error,anatomical nonsense,amateur,out of frame,multiple views, Steps: 28, CFG scale: 7.5, Sampler: Euler a, Seed: 3625896228, Size: 832x1216, Model: Illustrious-XL-v0.1, Version: f1.0.2-v1.10.1RC-latest-691-g37223711, Model hash: 3e15ba0038, Schedule type: Automatic, Discard penultimate sigma: True

 

--lowvram

 

[링크 : https://huggingface.co/stabilityai/models?search=sdxl]

[링크 : https://huggingface.co/stabilityai/sdxl-turbo/tree/main]

[링크 : https://huggingface.co/stabilityai/sdxl-vae/tree/main]

 

 

 

Posted by 구차니

아따 많이도 찾아봤었네 -_-

집에는 라즈베리 하나 켜놓고 회사에 켠 녀석을 집으로 SSH 접속하게 하고

집에서는 내부 아이피로 역으로 접속할수 있는 시스템을 만들려고 하는 중

 

[링크 : https://manpages.ubuntu.com/manpages/jammy/man1/autossh.1.html]

[링크 : https://lstm.tistory.com/10]

[링크 : https://m.clien.net/service/board/cm_linux/4344761]

[링크 : https://sangwonyoon.tistory.com/m/entry/Autossh로-SSH-연결-유지하기]

 

2018.05.14 - [프로그램 사용/ssh scp sftp] - reverse SSH

2021.01.03 - [프로그램 사용/ssh scp sftp] - reverse ssh

 

 

-------------------

2026.05.13

아래 링크의 옵션 참조했음

[링크 : https://donotlimityourself.tistory.com/33[

 

private(회사)

원격지에 2222 포트로 현재 pc의 22번 포트를 돌린다~ 라는 의미 인듯한데

그래서 listen에 추가로 포트가 열리지도 않았고, 정상적으로 실행이 되는 건가 보다.

$ ssh minimonk@집SSH도메인 -p 8022 -f -N -T -R 2222:localhost:22
minimonk@집SSH도메인's password: 
$ ps -ef | grep ssh
root         900       1  0  5월12 ?      00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
root        2298     900  0  5월12 ?      00:00:00 sshd: minimonk [priv]
minimonk    2385    2298  0  5월12 ?      00:05:27 sshd: minimonk@pts/0
root        5656     900  0  5월12 ?      00:00:00 sshd: minimonk [priv]
minimonk    5735    5656  0  5월12 ?      00:00:00 sshd: minimonk@pts/7
minimonk   10717       1  0 09:58 ?        00:00:00 ssh minimonk@집SSH도메인 -p 8022 -f -N -T -R 2222:localhost:22
minimonk   10719    5736  0 09:58 pts/7    00:00:00 grep --color=auto ssh

$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:39557         0.0.0.0:*               LISTEN      3128/language_serve 
tcp        0      0 127.0.0.1:5803          0.0.0.0:*               LISTEN      5350/llama-server   
tcp        0      0 127.0.0.1:38605         0.0.0.0:*               LISTEN      3128/language_serve 
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:6012          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:45837         0.0.0.0:*               LISTEN      6184/language_serve 
tcp        0      0 0.0.0.0:7860            0.0.0.0:*               LISTEN      5584/venv/bin/pytho 
tcp        0      0 127.0.0.1:36141         0.0.0.0:*               LISTEN      6184/language_serve 
tcp        0      0 127.0.0.1:36197         0.0.0.0:*               LISTEN      6184/language_serve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:44747         0.0.0.0:*               LISTEN      3016/antigravity    
tcp        0      0 127.0.0.1:35159         0.0.0.0:*               LISTEN      6061/exe            
tcp        0      0 127.0.0.1:34279         0.0.0.0:*               LISTEN      3016/antigravity    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::5900                 :::*                    LISTEN      1502/gnome-remote-d 
tcp6       0      0 ::1:631                 :::*                    LISTEN      -                   
tcp6       0      0 :::8080                 :::*                    LISTEN      5256/./llama-swap   
tcp6       0      0 :::22                   :::*                    LISTEN      -                   
tcp6       0      0 ::1:6010                :::*                    LISTEN      -                   
tcp6       0      0 ::1:6012                :::*                    LISTEN      -                   
tcp6       0      0 :::3389                 :::*                    LISTEN      1502/gnome-remote-d 

 

public(내 집)

접속전
$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -  

접속후
$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:2222          0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -                   
tcp6       0      0 ::1:2222                :::*                    LISTEN      -      

 

SSH 옵션을 보면 -fNTR 에서  -f이 백그라운드로 뜨게 하느것이고

NT는 터미널 관련, 명령 실행 관련

R은 원격지 포트에 내껄 붙인다는 의미

역시 NTR은 좋은것이여... (응?)

     -f      Requests ssh to go to background just before command execution.
             This is useful if ssh is going to ask for passwords or
             passphrases, but the user wants it in the background.  This im‐
             plies -n.  The recommended way to start X11 programs at a remote
             site is with something like ssh -f host xterm.

             If the ExitOnForwardFailure configuration option is set to “yes”,
             then a client started with -f will wait for all remote port for‐
             wards to be successfully established before placing itself in the
             background.  Refer to the description of ForkAfterAuthentication
             in ssh_config(5) for details.


     -N      Do not execute a remote command.  This is useful for just for‐
             warding ports.  Refer to the description of SessionType in
             ssh_config(5) for details.

     -T      Disable pseudo-terminal allocation.

     -R [bind_address:]port:host:hostport
     -R [bind_address:]port:local_socket
     -R remote_socket:host:hostport
     -R remote_socket:local_socket
     -R [bind_address:]port
             Specifies that connections to the given TCP port or Unix socket
             on the remote (server) host are to be forwarded to the local
             side.

 

이제 autossh를 설치하고

$ sudo apt-get install autossh
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  autossh
0 upgraded, 1 newly installed, 0 to remove and 47 not upgraded.
Need to get 29.2 kB of archives.
After this operation, 89.1 kB of additional disk space will be used.
Get:1 http://kr.archive.ubuntu.com/ubuntu jammy/universe amd64 autossh amd64 1.4g-1 [29.2 kB]
Fetched 29.2 kB in 0s (217 kB/s)   
Selecting previously unselected package autossh.
(Reading database ... 322586 files and directories currently installed.)
Preparing to unpack .../autossh_1.4g-1_amd64.deb ...
Unpacking autossh (1.4g-1) ...
Setting up autossh (1.4g-1) ...
Processing triggers for man-db (2.10.2-1) ...

 

 public 쪽에 로그인이 되도록 키를 복사하려는데 안되네 -_-???

아무튼 키를 생성하고 해주면 끝

$ ssh-copy-id -p 8022 minimonk@집SSH도메인
/usr/bin/ssh-copy-id: ERROR: No identities found

$ ssh-keygen

 

-f 를 넣으면 키를 넣어줘도 로그인이 안되서 일단 빼고 하니 되긴한데..

$ autossh -M -0 -o "ServerAliveinterval 30" -o "ServerAliveCountMax 3" -T -R 2222:localhost:22 minimonk@집SSH도메인 -p 2022

[링크 : https://sangwonyoon.tistory.com/entry/Autossh로-SSH-연결-유지하기]

 

autossh가 죽으면 어쩌지 싶어서 데몬으로 된 거 없나 찾아 봐야 할 듯.

[링크 : https://tecadmin.net/autossh-persistent-ssh-connections/]

 

 

+

여러 번의 인자를 사용하면 복수의 포트를 포워딩 할 수 있다.

ssh remote-host -L 8822:REMOTE_IP_1:22 -L 9922:REMOTE_IP_2:22

[링크 : https://stackoverflow.com/questions/29936948/ssh-l-forward-multiple-ports]

 

+

아래를 public 쪽 sshd_config 에 설정해주고 sshd를 재기동하고

$ cat /etc/ssh/sshd_config
# GatewayPorts no
GatewayPorts yes
$ sudo systemctl restart sshd

 

2222 대신 0.0.0.0:2222 라고 입력하고 실행하면

$ ssh minimonk@집SSH도메인 -p 8022 -f -N -T -R 0.0.0.0:2222:localhost:22

 

localhost로 되어있던걸

$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:2222          0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 ::1:2222                :::*                    LISTEN      -
tcp6       0      0 ::1:6010                :::*                    LISTEN      -

 

0.0.0.0 으로 바꾸어서 public 서버의 서비스 인것 처럼 붙일수도 있다.

$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 :::2222                 :::*                    LISTEN      -
tcp6       0      0 ::1:6010                :::*                    LISTEN      -

'프로그램 사용 > ssh scp sftp' 카테고리의 다른 글

ssh -t  (0) 2025.09.08
ssh-copy-id  (0) 2025.04.18
ssh socks proxy  (0) 2024.07.22
ssh ecdsa 미지원(ubuntu 22.04)  (0) 2023.05.30
ubuntu ssh x11 forwarding시 gnome 화면 끌어오기  (0) 2022.07.11
Posted by 구차니

음성인식 - 그림 들어가면 그리기

 

 

그림 넣고 캡션에 그림 있으면 img2img로 작동시키기

Posted by 구차니