Kopieren von Dateien im SSH-Modus auf einen Computer

579
Peter David Carter

Ich versuche, einige Website-Dateien auf einen Computer hochzuladen, in den ich SSHed bin, und ich bin mir nicht sicher, ob der richtige Befehl verwendet werden soll. Ich habe versucht, die cpBefehlsanweisungen nachzuschlagen, aber ich kann nicht herausfinden, was für den Remote-Computer in den Speicherplatz eingefügt werden soll, da ich davon ausgehe, dass meine lokale IP-Adresse von außen maskiert wird.

Wie kann ich also herausfinden, wie meine lokale IP-Adresse lautet, um Dateien von meinem Computer über die Befehlszeile, die auf dem Remote-Server aufgerufen wird, auf einen Remote-Server zu kopieren? (Ich cpgehe jetzt davon aus, dass der Linux-Befehl der beste Weg ist, dies zu tun?)

Derzeit muss ich nur über eine C-Panel-Oberfläche andere Dateien hochladen, was ziemlich umständlich ist und nur das Kopieren einer Datei erlaubt, was mit dem Wachstum der Website wahrscheinlich zu einem größeren Problem wird.

Jede Hilfe wäre sehr, sehr dankbar.

1
Dieser Link kann hilfreich sein - wurde in einer früheren Frage beantwortet - http://stackoverflow.com/questions/3710946/copying-files-across-computers-using-ssh-and-mac-os-x-terminal Mike Diglio vor 8 Jahren 0
Danke Mike, der Link ist nützlich, aber mir ist immer noch nicht klar, wie ich meine lokale IP-Adresse herausfinden und im Befehl cp verwenden kann. Der Link, zu dem Sie einen Link gepostet haben, scheint Informationen zur Verwendung von scp zu enthalten, nicht jedoch, wie Sie herausfinden können, wie Ihre IP-Adresse und / oder Ihr Hostname von einem Remote-Server erkannt werden. Peter David Carter vor 8 Jahren 0

1 Antwort auf die Frage

2
moonpoint

You should use the scp command, which allows one to copy files from one system to another using the SSH protocol, rather than the cp command. If your local computer is a Linux or OS X system, then you likely already have scp on the system. If your local computer is a Microsoft Windows system and you are using PuTTY, it also has a command line utility, pscp. Or you could use WinSCP, which provides a graphical user interface (GUI).

To copy multiple files at once, you can use an scp command similar to the following one, assuming you wished to copy all html files in the current directory on your local system to a server example.com and store them beneath a directory named public_html on the remote system. The directory path on the remote system will be relative to your home directory on that system. You can also specify your home directory with ~, e.g. ~/public_html/. The period at the end indicates you want to give the files the same name on the remote system as they have on the local system.

scp *.html your_remote_username@example.com:public_html/. 

See scp or sftp copy mulitple files with single command for other examples of copying mulitple files.

You should run the command outside of your current SSH session. The ssh command is for interactive logins whereas the scp, or alternatively, sftp, command is run separately for file transfers.

You don't need to know your local IP address for the command. But, if you want to know your local IP address, you can obtain it by visiting WhatIsMyIP with a browser on your local system. You would only need to know your local IP address to use the scp command if you were copying files in the opposite direction from the remote system to your local system. In that case the local system would also need to be functioning as an SSH server and have appropriate firewall rules configured.