
나는 세 대의 컴퓨터 HOME, WORK 및 SERVER를 가지고 있으며 다음을 통해 HOME에서 SERVER로 연결됩니다.
ssh -t <WORKusername>@<WORK> ssh -p23456 <SERVERusername>@localhost
나는해야한다HOME에서 SERVER로 파일 전송 하지만 파일을 그대로 둘 수가 없어요일하다
또한 나는해야 할 것입니다SERVER에서 HOME으로 파일 전송처리한 후 어떻게 해야 하나요?
나는 살펴보았다https://serverfault.com/questions/37629/how-do-i-do-multihop-scp-transfers그리고내 (세 번째) PC의 두 원격 호스트 사이의 scp하지만 SSH 구성을 변경할 수 없습니다.집기계
그리고 나는 이것을 시도했지만 아무데도 없었습니다.
$ scp -o ProxyCommand="ssh <WORKusername>@<WORK> nc localhost" ASPEC.zip <SERVERusername>@localhost:~/
<WORKusername>@<WORK>'s password:
This is nc from the netcat-openbsd package. An alternative nc is available
in the netcat-traditional package.
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-P proxy_username] [-p source_port]
[-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol]
[-x proxy_address[:port]] [hostname] [port[s]]
ssh_exchange_identification: Connection closed by remote host
lost connection
또한 다음을 시도했지만 이는 SERVER -> HOME에서 파일을 전송하는 것과 반대입니다.
ssh -t <WORKusername>@<WORK> "ssh -p 23456 <SERVERusername>@localhost \"cat file.zip\""
나는 또한 tar를 시도했지만 작동하지 않았습니다.
tar c file.zip | ssh -t <WORKusername>@<WORK> "ssh -p 23456 <SERVERusername>@localhost | tar x"
Pseudo-terminal will not be allocated because stdin is not a terminal.
<WORKusername>@<WORK>'s password:
Pseudo-terminal will not be allocated because stdin is not a terminal.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
그런 다음 다음을 시도했습니다.
# From home:
$ ssh -L 23456:<SERVERusername>@localhost:22 <WORKusername>@<WORK>
# After ssh, in WORK:
$ ssh -p 23456 <SERVERusername>@localhost
# From home:
$ scp -P file.zip <SERVERusername>@localhost:~/
그리고 scp 명령을 내릴 때 이러한 오류가 발생했습니다.
# on WORK terminal:
channel 3: open failed: administratively prohibited: open failed
# on SERVER terminal:
ssh_exchange_identification: Connection closed by remote host
lost connection
rsync도 시도했지만 작동하지 않았습니다.
rsync -e "ssh -A -t <WORKusername>@<WORK>e ssh -p23456 <SERVERusername>@localhost" file.zip :~/
HOME에서 SCP를 사용하여 파일을 SERVER로 전송하려면 어떻게 해야 하나요?
그리고 SERVER에서 HOME으로?
답변1
이것을 사용해 보십시오:
scp -P SERVERPORT -o 'ProxyCommand ssh -p WORKPORT WORKUSER@WORK nc %h %p 2>/dev/null' localfile SERVERUSER@SERVER:remotefile
ProxyCommand
SERVER:SERVERPORT에 연결된 WORK 호스트에 프록시를 생성합니다(참조:체크 안함). SSH 변수 %h
는 %p
각각 대상 호스트와 포트입니다.
답변2
다음과 같이 시도해 볼 수 있습니다.
cat localfile | ssh <WORKusername>@<WORK> "ssh -p23456 <SERVERusername>@localhost 'cat > remotefile'"