Skip to main content

Linux SCP: Securely Transfer Files and Folders Over SSH

HardReset.InfoJanuary 1, 20269 min35 views
7 connections·10 entities in this video→

Understanding SCP and SSH

  • πŸ’‘ SCP (Secure Copy) is a command-line tool for transferring files and directories securely over SSH.
  • πŸ”‘ To use SCP, SSH must be installed and running on your Linux system.

Installing and Enabling SSH

  • πŸ’» To check if SSH is installed, use the command: sudo systemctl status ssh.
  • βš™οΈ If SSH is not installed, install it using: sudo apt install openssh-server.
  • βœ… After installation, enable and start the SSH service with: sudo systemctl enable --now ssh.
  • πŸ” Verify that SSH is active and running with sudo systemctl status ssh.

Network Configuration and IP Address

  • 🌐 When using SCP on virtual machines, it's crucial to set the network adapter to Bridge mode instead of NAT.
  • ⚠️ NAT mode can cause IP address issues (e.g., starting with 10.0.0.x) that prevent SCP from working correctly.
  • IP addresses in Bridge mode typically start with 192.168.x.x.
  • πŸ” You can find your machine's IP address using a command like ip a or ifconfig.

Transferring Single Files with SCP

  • πŸ“ Create a test file using echo 'SCP test file' > test.txt.
  • πŸ“€ The basic SCP syntax for transferring a file is: scp <local_file> <username>@<IP_address>:<destination_path>.
  • πŸ”‘ You will be prompted to authenticate, usually by entering your password or using SSH keys.
  • βœ… After successful transfer, verify the file exists at the destination.

Transferring Folders with SCP

  • πŸ“ To copy an entire folder, use the recursive option with SCP: scp -r <local_folder> <username>@<IP_address>:<destination_path>.
  • πŸ“‚ This command copies the folder and all its contents.
  • βœ… Navigate to the destination directory to verify that the folder and its files have been transferred correctly.
Knowledge graph10 entities Β· 7 connections

How they connect

An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.

Hover Β· drag to explore
10 entities
Chapters4 moments

Key Moments

Transcript35 segments

Full Transcript

Topics14 themes

What’s Discussed

SCPSSHSecure CopyFile TransferLinuxOpenSSH ServerCommand LineVirtual MachinesBridge AdapterNATIP AddressRecursive CopyPassword AuthenticationSSH Keys
Smart Objects10 Β· 7 links
ProductsΒ· 5
MediasΒ· 3
ConceptΒ· 1
LocationΒ· 1