한 외부 서버에서 다른 서버로의 SCP 사용자 정의 포트 (xxxx)를

로컬 서버에서 SCP를 사용하여 한 원격 서버에서 다른 원격 서버로 파일을 복사하려고합니다 (원격 서버 모두 사용자 정의 포트 (xxxx)를 사용함)

나는 노력하고있다 :

scp -r -P xxxx root@xxx.xxx.xxx.111:/home/myimages/images.tar.gz root@xxx.xxx.xxx.222:/home/myimages/images.tar.gz

그러나 다음과 같은 오류가 발생합니다.

ssh: connect to host xxx.xxx.xxx.222 port 22: Connection timed out

어떤 제안?



답변

첫 번째 원격 호스트에서 두 번째 원격 호스트로 직접 인증이 작동하는지 확인 했습니까?

scp user@host:/file user@otherhost:/otherfile 속기

ssh user@host scp /file user@otherhost:/otherfile

그것은 나를 생각하게합니다 :

ssh -p XXX user@host scp -P XXX /file user@otherhost:/otherfile 작동 할 수 있습니다.


답변

scp특수 포트를 두 번째 서버에서도 사용해야한다는 것을 알지 못하는 것 같습니다 . 명시 적으로 전화 ssh를 걸어 원격 scp전송 을 시작할 수 있습니다 .

ssh -P xxxx user@host scp -P xxxx /file user@otherhost:/otherfile


답변

에 서버를 정의하십시오 ( .ssh/config file예 :

Host foobar
User youruser
Port 2222
Hostname the.real.hostname

Host foobar2
User youruser
Port 2222
Hostname the2.real.hostname

그런 다음 간단하게 수행 할 수 있습니다.

scp foobar:file foobar2:

정의 된 사용자 정의 포트를 사용합니다.


답변

서로 볼 수없는 원격 서버가 있지만 로컬 서버에서 둘 다 볼 수 있습니다. 원격 서버의 ssh 디먼은 다른 비표준 ssh 포트에서 청취하고 있습니다. 이것이 내가 이것을하는 방법입니다.

ssh -p 111 userA@remote1 'cat myfile' | ssh -p 222 userB@remote2 'cat - > myfile'

두 번째 ssh 명령은 먼저 비밀번호를 요청한 다음 remote1은 userA의 비밀번호를 요청합니다. 내 환경에서는 ssh 인증 키를 설정 한 경우이 기능이 자동화되어있을 수 있습니다.


답변