내 질문은 다음과 같습니다ubuntu 인스턴스를 사용하여 AWS에서 ssh용 배스천 호스트를 설정하려면 어떻게 해야 합니까?
나는 다음을 성공적으로 수행할 수 있습니다.
root@e183d80cdabc# ssh -J [email protected] [email protected]
Last login: Sat Sep 4 13:14:17 2021 from 10.240.0.30
==> SUCCESS! ==> ubuntu@ip-10-240-0-20:~$
하지만 ~/.ssh/config 파일 접근 방식을 시도하면 실패합니다. 사용된 명령:
# ssh 10.240.0.20
# ssh [email protected]
# ssh -i ~/.ssh/id_rsa [email protected]
ssh: connect to host 10.240.0.20 port 22: Connection refused
내 ~/.ssh/config는 다음과 같습니다.
root@e183d80cdabc# cat $HOME/.ssh/config
Host bastion
HostName 54.170.186.144
Host remote
HostName 10.240.0.20
ProxyJump bastion
다음과 같이 AWS에서 우분투를 실행하고 있습니다.
ubuntu@ip-10-240-0-30:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
필드 를 추가해 보았지만 User ubuntu
도움이 되지 않습니다.
내 /etc/ssh/ssh_config
서버는 다음과 같습니다.
Host *
ForwardX11Trusted yes
IdentityFile ~/.ssh/id_rsa
Port 22
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
업데이트 나는 지금 verbose 옵션을 사용하고 있습니다.
root@e183d80cdabc# ssh -vvv 10.240.0.20
OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /root/.ssh/config
debug1: /root/.ssh/config line 2: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 10.240.0.20 is address
debug2: ssh_connect_direct
debug1: Connecting to 10.240.0.20 [10.240.0.20] port 22.
debug1: connect to address 10.240.0.20 port 22: Connection refused
ssh: connect to host 10.240.0.20 port 22: Connection refused
점프 호스트를 사용하지 않는 것 같고(즉, 요새를 건너뛰고) 직접 가고 있으며 실패합니다.
어떤 아이디어라도 크게 감사드립니다! 감사합니다
================================================= =======
업데이트: 2021-09-04-15-44 - 솔루션 포함 모두 감사합니다. 아래에 답변으로 표시했습니다.
일치가 수행되므로 올바른 구성은 HostName을 사용하지 않습니다.주인. 또한 IP 주소에 와일드카드를 포함할 수 있었는데, 이것이 바로 제가 원하는 것이었습니다.
SSH 구성
root@e183d80cdabc# cat $HOME/.ssh/config
Host bastion
HostName 63.33.206.201
User ubuntu
Host 10.240.0.*
ProxyJump bastion
User ubuntu
그리고짜잔!
# ssh 10.240.0.20
...
ubuntu@ip-10-240-0-20:~$
답변1
일치는 Host
스탠자가 아닌 스탠자 에서 수행됩니다 HostName
.
노력하다:
ssh ubuntu@remote
답변2
명령줄의 차이점
ssh -J [email protected] [email protected]
구성을 참조하기 위해 권장하는 작업
ssh remote
후자는 IP도 없고두 컴퓨터 모두에 로그인할 사용자명령줄에서 - SSH 구성을 편집하여 다음을 포함해야 합니다.모두더 이상 명령줄에 전달하지 않는 정보:
# $HOME/.ssh/config
### The Bastion Host
Host bastion
HostName 54.170.186.144
User ubuntu
### The Remote Host
Host remote
HostName 10.240.0.20
User ubuntu
ProxyJump bastion
업데이트: 그렇습니다. 이론적으로는~할 수 있다IP 주소와 일치하도록 스탠자를 구성하는 것이 Host
좋습니다.~에 맞서그렇게.
특정 IP 주소를 사용하여 호스트에 직접 연결되지 않은 경우 다음을 통해 참조해야 합니다.이름- 여러 호스트에 동일한(개인) IP 공간이 할당되어 있으면 각각에 대해 올바른 ProxyJump 구성을 할당할 수 없을 때 어떤 일이 발생하는지 상상해 보십시오.
호스트를 참조하기 위해 주소를 사용하는 것이 바람직하지 않은 또 다른 이유는 여러 주소 계열을 통해 호스트에 연결할 수 있다는 것입니다. 호스트가 IPv4 및 IPv6을 통해 연결할 수 있는 경우 SSH 연결이 프로토콜에 구애받지 않고 실제로 제한하려는 경우에만 플래그를 추가하기를 원할 것입니다. (자동) 선택.