Secure File Transfer Protocol (SFTP) is a widely used protocol for transferring files securely between local and remote systems. In this tutorial, we will walk you through the process of using SFTP to download remote files.
Before we start, it's important to note that SFTP is typically used in a Unix-based system like Linux or MacOS. For Windows users, you might want to use software like PuTTY or FileZilla that can handle SFTP connections.
What is Shown Here?
This tutorial will show you how to connect to a virtual machine running Odoo 15 Community, distributed through Bitnami, on Google Compute infrastructure via sftp. You will connect to the instance through the Google console via SSH, then connect to the file system via sftp from your local command prompt using a public-private key pair that you generate locally and install on the Odoo server. Finally, you will use the connection to download a zipped folder securely to your desktop.
What is SFTP?
SFTP stands for SSH File Transfer Protocol or Secure File Transfer Protocol. It's a protocol used for transferring files over a secure channel. SFTP encrypts both commands and data providing effective protection against common network security risks.
What is Odoo ERP?
Odoo ERP is a comprehensive enterprise resource planning (ERP) software that enables businesses to manage their operations more efficiently. It offers a range of features and modules that can be customized to meet the specific needs of a business.
What is Bitnami?
Bitnami is a company that provides ready-to-run applications for the cloud, as docker images, as kubernetes charts and as locally executable applications. It offers a range of applications, including Odoo ERP, that can be easily deployed on popular cloud platforms such as Google Cloud Platform, Amazon Web Service and Mircosoft Azure.
What is Google Cloud Platform?
Google Cloud Platform is a suite of public cloud services offered by Google. It enables businesses to run their applications and store their data in Google's data centers. Google Cloud Platform offers a range of services, including compute, storage, networking, and big data products.
- You should have SSH access to the remote server.
- Ensure you have the necessary permissions to download files from the server.
- Familiarity with command-line interfaces.
This tutorial is shown on a Google Cloud Compute Instance, however instructions are similar for many platforms.
Steps to Download Files Using SFTP
Step 1: Generate a public and private key
We need to generate a security key to use for authentication into the Odoo server over sftp. We do this by running the command cmd and open using Administrator privileges.
Running the following code will generate a key pair with the rsa algorithm. Replace KEY-NAME with the name of the keys and SSH-USERNAME with the username when you login via SSH through the Google Console. It will be in the form of `username@instance-name`
ssh-keygen -t rsa -f /KEY-NAME -C SSH-USERNAME
The keys will be generated in the Root drive folder if you use this format.
Step 2: Restrict permissions on keys to current user only
Edit the privileges to the two keys that you generated. Give full control to your current user and remove all others from the list.
Step 3: Install the public key on the odoo server (Google Compute Instance)
Login to your Google Console and go to your computer instance. In the compute instance details screen find the SSH Keys section and use Add New button to paste in the contents of the KEY-NAME.pub key you generated in step 1.
Step 4: Connect to the Remote Server
Open your terminal as administrator and type the following command:
sftp -i /IdentityFile username@ipAddress
Replace 'username' with your actual username on the server and 'hostname' with the actual hostname or IP address of the server. You can find the username when you connect to a Google Cloud VM via SSH through the console. The ip address for your instance is in the instance details page.
Step 5: Navigate to the Directory
Once you're connected to the remote server, you can navigate to the directory containing the file you want to download. You can do this using the `cd` command followed by the directory path. For example:
Step 3: Download the File
To download the file, we will use the `get` command followed by the name of the file. For example:
This command will download the file to your local system in the current directory.
If you want to download the file to a specific directory, you can specify the local path as follows:
get remoteFile localPath
For multiple files, you can use wildcard characters or specify the `mget` command. For example, to download all .txt files, you would use:
Step 4: Exit the SFTP Environment
Once you have successfully downloaded the file(s), you can exit the SFTP environment by typing:
This will take you back to your local system's command prompt.
Downloading files using SFTP is a secure and efficient way to transfer data between local and remote systems. By following this step-by-step tutorial, you should now be able to download files from a remote server using SFTP. Always remember to keep your login details secure and only download files that you have permission to access. Happy downloading!
Remember, practice makes perfect. Don't hesitate to explore more commands and try to upload files using SFTP as well. The more you use these commands, the more comfortable you'll become navigating the SFTP environment.