다음 단계에서는 전달 SSH 터널을 사용하여 소스 데이터베이스에 대한 연결을 설정하는 방법을 설명합니다.
1단계: 터널을 종료할 호스트 선택
데이터베이스에 대해 SSH 터널 액세스를 설정하는 첫 번째 단계는 터널을 종료하는 데 사용할 호스트를 선택하는 것입니다. 데이터베이스 호스트 자체 또는 별도의 호스트(터널 서버)에서 터널을 종료할 수 있습니다.
데이터베이스 서버 사용
데이터베이스에서 터널을 종료하면 단순성 이점이 있습니다. 관련된 호스트가 하나 적기 때문에 추가적인 머신 및 관련 비용이 발생하지 않습니다. 단점은 데이터베이스 서버가 인터넷에 직접 액세스할 수 없는 보호 네트워크에 있을 수 있다는 것입니다.
터널 서버 사용
별도의 서버에서 터널을 종료하면 인터넷에서 데이터베이스 서버에 액세스할 수 없다는 이점이 있습니다. 터널 서버가 손상된 경우 데이터베이스 서버에서 한 단계가 삭제됩니다. 터널 서버에서 중요하지 않은 소프트웨어와 사용자를 모두 삭제하고 침입 감지 시스템(IDS)과 같은 도구를 사용하여 면밀하게 모니터링하는 것이 좋습니다.
터널 서버는 다음과 같은 모든 Unix 또는 Linux 호스트일 수 있습니다.
SSH를 사용해서 인터넷에서 액세스할 수 있습니다.
데이터베이스에 액세스할 수 있습니다.
2단계: IP 허용 목록 만들기
데이터베이스에 대해 SSH 터널 액세스를 설정하는 두 번째 단계는 일반적으로 TCP 포트 22에서 SSH를 사용하여 터널 서버 또는 데이터베이스에 연결하도록 네트워크 트래픽을 허용하는 것입니다.
Datastream 리소스가 생성된 각 리전의 IP 주소에서 네트워크 트래픽을 허용합니다.
3단계: SSH 터널 사용
연결 프로필 구성에 터널 세부정보를 제공합니다. 자세한 내용은 연결 프로필 만들기를 참고하세요.
SSH 터널 세션을 인증하려면 Datastream에 터널 계정의 비밀번호 또는 고유한 비공개 키가 필요합니다. 고유한 비공개 키를 사용하려면 OpenSSH 또는 OpenSSL 명령줄 도구를 사용하여 키를 생성하면 됩니다.
Datastream은 Datastream 연결 프로필 구성의 일부로 비공개 키를 안전하게 저장합니다. 배스천 호스트의 ~/.ssh/authorized_keys 파일에 공개 키를 수동으로 추가해야 합니다.
비공개 키와 공개 키 생성
다음 방법을 사용하여 SSH 키를 생성할 수 있습니다.
ssh-keygen: SSH 키 쌍을 생성하는 OpenSSH 명령줄 도구입니다.
유용한 플래그:
-t: 만들 키의 유형을 지정합니다(예:
ssh-keygen -t rsa
ssh-keygen -t ed25519
-b: 생성할 키의 키 길이를 지정합니다. 예를 들면 다음과 같습니다.
ssh-keygen -t rsa -b 2048
-y: 비공개 OpenSSH 형식 파일을 읽고 OpenSSH 공개 키를 표준 출력에 출력합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Forward SSH tunnel\n\nThe following steps describe how to set up connectivity to a source database using a forward SSH tunnel.\n\nStep 1: Choose a host on which to terminate the tunnel\n------------------------------------------------------\n\nThe first step to set up SSH tunnel access for your database is to choose the host that will be used to terminate the tunnel. The tunnel can be terminated on either the database host itself, or on a separate host (the tunnel server).\n\n### Use the database server\n\nTerminating the tunnel on the database has the advantage of simplicity. There's one fewer host involved, so there are no additional machines and their associated costs. The disadvantage is that your database server might be on a protected network that doesn't have direct access from the internet.\n\n### Use a tunnel server\n\nTerminating the tunnel on a separate server has the advantage of keeping your database server inaccessible from the internet. If the tunnel server is compromised, then it's one step removed from the database server. We recommend that you remove all non-essential software and users from the tunnel server and closely monitor it with tools, such as an intrusion detection system (IDS).\n\nThe tunnel server can be any Unix or Linux host that:\n\n1. Can be accessed from the internet using SSH.\n2. Can access the database.\n\n | **Note:** For managed services, the tunnel server must be external to the source database. If your source database is self-hosted, you can set up the tunnel server on the same server or virtual machine (VM) that runs the source database.\n\nStep 2: Create an IP allowlist\n------------------------------\n\nThe second step to set up SSH tunnel access for your database is to allow network traffic to reach the tunnel server or the database host using SSH, which is generally on TCP port 22.\n\nAllow network traffic from each of the [IP addresses for the\nregion](/datastream/docs/ip-allowlists-and-regions) where Datastream\nresources are created.\n\nStep 3: Use the SSH tunnel\n--------------------------\n\nProvide the tunnel details in the connection profile configuration. For more\ninformation, see [Create a connection\nprofile](/datastream/docs/create-connection-profiles).\n\nTo authenticate the SSH tunnel session, Datastream requires either the password for the tunnel account, or a unique private key. To use a unique private key, you can use OpenSSH or OpenSSL command-line tools to generate keys.\n\nDatastream stores the private key securely as part of the Datastream connection profile configuration. You must add the public key manually to the bastion host's `~/.ssh/authorized_keys` file.\n\n### Generate private and public keys\n\nYou can generate SSH keys using the following method:\n\n- `ssh-keygen`: An OpenSSH command-line tool to generate SSH key pairs.\n\n Useful flags:\n - `-t`: Specifies the type of key to create, for example:\n\n `ssh-keygen -t rsa`\n\n `ssh-keygen -t ed25519`\n - `-b`: Specifies the key length in the key to create, for example:\n\n `ssh-keygen -t rsa -b 2048`\n - `-y`: Reads a private OpenSSH format file and prints an OpenSSH public key to standard output.\n\n - `-f`: Specifies the filename of the key file, for example:\n\n `ssh-keygen -y [-f `\u003cvar translate=\"no\"\u003eKEY_FILENAME\u003c/var\u003e`]`\n\n For more information about supported flags, see [OpenBSD documentation](https://man.openbsd.org/ssh-keygen).\n\nYou can generate a private PEM key using the following method:\n\n- `openssl genpkey`: An OpenSSL command-line tool to generate a PEM private key.\n\n Useful flags:\n - `algorithm`: Specifies the public key algorithm to use, for example:\n\n `openssl genpkey -algorithm RSA`\n - `-out`: Specifies the filename to which to output the key, for example:\n\n `openssl genpkey -algorithm RSA -out `\u003cvar translate=\"no\"\u003ePRIVATE_KEY_FILENAME\u003c/var\u003e`.pem`\n | To use the key generated by this command, you need to generate a public OpenSSH key for it using the following command:\n |\n | `ssh-keygen -y -f `\u003cvar translate=\"no\"\u003ePRIVATE_KEY_FILENAME\u003c/var\u003e`.pem \u003e\n | `\u003cvar translate=\"no\"\u003ePUBLIC_KEY_FILENAME\u003c/var\u003e`.pub`.\n | You can then add the \u003cvar translate=\"no\"\u003ePUBLIC_KEY_FILENAME\u003c/var\u003e`.pub` key to the `~/.ssh/authorized_keys` file.\n\n \u003cbr /\u003e\n\n For more information about supported flags, see [OpenSSL documentation](https://www.openssl.org/docs/man1.1.1/man1/openssl-genpkey.html).\n\nWhat's next\n-----------\n\n- Learn how about other network [connectivity methods](/datastream/docs/network-connectivity-options)."]]