Wie man über zwei SSHs scp

Wie man über zwei SSHs scp

Ich habe drei Computer: HOME, WORK und SERVER. Die Verbindung von HOME zum SERVER erfolgt über:

ssh -t <WORKusername>@<WORK> ssh -p23456 <SERVERusername>@localhost

Ich mussÜbertragen Sie die Datei von HOME auf den SERVER aber ich kann die Datei nicht verlassen inARBEITEN

Außerdem müsste ichÜbertragen Sie eine Datei vom SERVER nach HOMEwie mache ich das nach der Verarbeitung?

Ich habe mir angesehenhttps://serverfault.com/questions/37629/wie-führe-ich-multihop-scp-transfers durchUndscp zwischen zwei Remote-Hosts von meinem (dritten) PCaber ich bin nicht in der Lage, die SSH-Konfiguration auf dem zu ändernHEIMMaschine

Und ich habe dies versucht, bin aber nicht weitergekommen:

$ 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

Ich habe auch Folgendes versucht, aber dies ist das Gegenteil zum Übertragen von Dateien von SERVER -> HOME:

ssh -t <WORKusername>@<WORK> "ssh -p 23456 <SERVERusername>@localhost \"cat file.zip\""

Ich habe auch Tar probiert, aber das hat nicht funktioniert:

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

Dann habe ich versucht:

# 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:~/

Und ich bekomme diesen Fehler, wenn ich den scp-Befehl eingebe,

# on WORK terminal:
channel 3: open failed: administratively prohibited: open failed

# on SERVER terminal:
ssh_exchange_identification: Connection closed by remote host
lost connection

Ich habe auch rsync ausprobiert, aber es hat nicht funktioniert:

rsync -e "ssh -A -t <WORKusername>@<WORK>e ssh -p23456 <SERVERusername>@localhost" file.zip :~/

Wie kann ich per SCP von HOME eine Datei auf den SERVER übertragen?

Und auch vom SERVER nach HOME?

Antwort1

Versuchen Sie Folgendes zu verwenden:

scp -P SERVERPORT -o 'ProxyCommand ssh -p WORKPORT WORKUSER@WORK nc %h %p 2>/dev/null' localfile SERVERUSER@SERVER:remotefile

ProxyCommandErstellen Sie den Proxy auf dem WORK-Host, der mit SERVER:SERVERPORT verbunden ist (siehekeine). %hund %psind SSH-Variablen – jeweils Zielhost und Port.

Antwort2

Sie können Folgendes versuchen:

cat localfile | ssh <WORKusername>@<WORK> "ssh -p23456 <SERVERusername>@localhost 'cat > remotefile'"

verwandte Informationen