To upload a file from your local computer to a remote folder via SSH, you can use the scp
(Secure Copy) command. Make sure the file you want to upload and the remote folder exist, and you have write permissions in the remote folder.
Here is an example of how to do it:
Assuming you have a file named “my-file.txt” on your local computer and you want to copy it to the remote folder “/path/to/remote/folder” on the SSH server. Use the following command in your local terminal:
scp my-file.txt user@server-address:/path/to/remote/folder/
Make sure to replace the following with the corresponding information:
my-file.txt
: The name of the file you want to copy.user
: Your username on the SSH server.server-address
: The address or IP of the SSH server you’ve connected to previously./path/to/remote/folder/
: The full path of the remote folder where you want to copy the file.
Then, you will be prompted to enter your account’s password on the SSH server (unless you are using public key authentication).
Download a File from a Remote Folder:
If you want to download a file from a remote folder to your local computer using scp
, you can do so with the following command:
scp usuario@direccion-del-servidor:/ruta/a/la/carpeta/remota/miarchivo.txt /ruta/en/ordenador/local/
This will copy the “miarchivo.txt” file from the remote folder to the “/ruta/en/ordenador/local/” folder on your local computer.
Additional Options:
1. View the Progress of the Transfer:
If you want to see detailed progress of the file transfer, you can use the -v
(verbose) option of scp
:
scp -v miarchivo.txt usuario@direccion-del-servidor:/ruta/a/la/carpeta/remota/
2. Copy Entire Directories:
If you want to copy an entire directory instead of a single file, you can use the -r
(recursive) option:
scp -r directorio-local usuario@direccion-del-servidor:/ruta/a/la/carpeta/remota/
Replace “directorio-local” with the path to the local directory you want to copy.
Conclusion
The scp
command is a useful tool for securely transferring files between your local computer and a remote server via SSH. With the aforementioned options, you can customize your file transfers according to your needs. Explore the possibilities of scp
to manage your files efficiently!