# 컨테이너에서 SSH 사용

{% hint style="warning" %}
Edgegap은 프로덕션 배포에서 SSH 서비스를 외부에 노출하는 것을 권장하지 않습니다.
{% endhint %}

### Dockerfile 수정

우리는 다른 Docker를 사용하여 도커 컨테이너를 빌드할 것입니다 `Dockerfile` 이 버전에서.

OpenSSH 서비스를 설치하고 활성화해야 합니다. 서버에 접속할 사용자와 비밀번호를 생성하세요.

다음에서 실행 중인 컨테이너에선 **Alpine**, 다음을 병합하세요:

```dockerfile
RUN apk --update add --no-cache openssh bash
RUN sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config
RUN echo "tester:$ecureP@ss" | chpasswd

EXPOSE 22
```

다음에서 실행 중인 컨테이너에선 **Ubuntu**, 다음을 추가하세요:

```dockerfile
RUN apt-get update
RUN apt-get install openssh-server sudo -y

RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000
RUN echo 'tester:$ecureP@ss' | chpasswd

EXPOSE 22
```

엔트리포인트에서 다음 명령을 추가해야 합니다:

```sh
service ssh start
```

서버 시작을 테스트하기 위해 docker run 명령을 사용하여 배포를 로컬에서 테스트할 것을 권장합니다.

테스트가 완료되면 컨테이너 저장소에 새 버전을 푸시할 수 있습니다.

### Edgegap에서

다음과 같은 이름의 버전을 두는 것을 권장합니다: `-dev` 또는 서비스에 맞는 다른 명칭. 이렇게 하면 Edgegap 인프라를 사용하여 테스트를 하고 컨테이너에 쉽게 로그인할 수 있는 옵션을 갖게 됩니다.

1. 앱의 새 버전을 생성하고 `TCP 포트 22 노출(Expose TCP Port 22)`
2. 방금 생성한 새 버전을 사용하여 배포를 생성하세요
3. 서비스가 실행(Ready)되면 배포 정보를 확인하세요. 포트 22의 외부 포트 매핑을 볼 수 있습니다.
4. Putty를 사용해 배포의 FQDN 또는 IP와 사용된 포트 매핑으로 연결할 수 있습니다
5. 당신이 구성한 사용자 이름과 비밀번호.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.edgegap.com/docs.edgegap.com-ko/docs/tools-and-integrations/container/ssh.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
