SSH를 통해 Docker 컨테이너에서 원격 서버에 연결할 수 없습니다.

SSH를 통해 Docker 컨테이너에서 원격 서버에 연결할 수 없습니다.

내 호스트 서버에서 내 사용자를 생성했습니다.비공개 및 공개열쇠. 공개 키 값을 원격 서버 파일에 복사했습니다 authorized_keys. .ssh 폴더를 다음과 같이 사용하도록 새 도커 컨테이너 인스턴스를 매핑했습니다.용량그리고 설정회로망호스트의 네트워크에.

-v /home/jenkins/.ssh:/home/jenkins/.ssh --network host'

이제 컨테이너 내부의 원격 시스템에 SSH 인증을 시도합니다.

ssh -vvv -o StrictHostKeyChecking=no [email protected]

내 사용자에게 SSH 비밀번호가 없습니다. SSH 서버 측의 출력:

sshd: Failed none for jenkins from 10.7.148.219 port 42058 ssh2
sshd: Failed password for jenkins from 10.7.148.219 port 42058 ssh2

클라이언트 출력:

+ ssh -vvv -o 'StrictHostKeyChecking=no' [email protected]
OpenSSH_8.6p1, OpenSSL 1.1.1l  24 Aug 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 10.7.175.143 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/root/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/root/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: ssh_connect_direct: entering
debug1: Connecting to 10.7.175.143 [10.7.175.143] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Connection established.
.................................

debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug3: no such identity: /root/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /root/.ssh/id_dsa
debug3: no such identity: /root/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /root/.ssh/id_ecdsa
debug3: no such identity: /root/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /root/.ssh/id_ecdsa_sk
debug3: no such identity: /root/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /root/.ssh/id_ed25519
debug3: no such identity: /root/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /root/.ssh/id_ed25519_sk
debug3: no such identity: /root/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /root/.ssh/id_xmss
debug3: no such identity: /root/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: userauth_kbdint: disable: no info_req_seen
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: 
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,password,keyboard-interactive).

Docker 컨테이너에서 내 신원을 어떻게든 인증할 수 있나요?

답변1

ssh디버그 출력에서 ​​다음과 같이 명령을 실행했기 때문에 home 폴더 대신 home 폴더에서 ssh 키를 검색하는 것을 볼 수 있습니다 root.rootjenkins

debug1: Trying private key: /root/.ssh/id_rsa
debug3: no such identity: /root/.ssh/id_rsa: No such file or directory

-i <identity_file>명령에 플래그를 추가하여 개인 키의 위치를 ​​제공해야 합니다 ssh.

관련 정보