In this tutorial, you will learn how to securely transfer files between Ubuntu systems that are on the same network. We will cover two commonly used methods: SCP (Secure Copy Protocol) and SFTP (SSH File Transfer Protocol).
- Two Ubuntu systems connected to the same network.
- SSH (Secure Shell) installed and configured on both systems.
Before transferring files, you need to know the IP address of the destination system. Here's how you can find it:
- Using the
ifconfig
command:
Open a terminal on the destination system and type:
ifconfig
Look for the network interface connected to your local network (typically eth0
or wlan0
), and locate the inet
field. The IP address listed in this field is the IP address of the system.
- Using the hostname command:
Open a terminal on the destination system and type:
hostname -I
This command will display the IP addresses associated with the system.
- Using a graphical network manager:
If you're using a desktop environment, you can often find network information, including the IP address, through the network manager GUI. Look for network settings or connection information.
SCP allows you to securely transfer files between hosts on a network. It relies on SSH for data transfer and provides the same authentication and security as SSH.
-
Open a terminal on the system from which you want to send the file.
-
Use the following command format to transfer the file:
scp /path/to/your/file username@destination_host:/path/to/destination/directory
/path/to/your/file
with the path to the file you want to send.- username with the username on the destination system.
- destination_host with the IP address or hostname of the destination system.
/path/to/destination/directory
with the directory where you want to place the file on the destination system.
scp /home/user/example.txt user@192.168.1.2:/home/user/
You will be prompted for the password of the destination user.
SFTP provides a secure way to transfer files between hosts over SSH. It allows interactive file operations, similar to using FTP.
- Open a terminal on the system from which you want to send the file.
- Type the following command to start an SFTP session:
sftp username@destination_host
username
with the username on the destination system.destination_host
with the IP address or hostname of the destination system. You'll be prompted for the password of the destination user.
- Once logged in, you can use commands like put to upload files:
put /path/to/your/file /path/to/destination/directory
/path/to/your/file
with the path to the file you want to send./path/to/destination/directory
with the directory where you want to place the file on the destination system.
put /home/user/example.txt /home/user/
This will transfer example.txt to the home directory of the destination user.
Choose the method that best suits your needs and preferences. Both methods provide secure file transfer capabilities within the same network.