🌐 Linux/Unix: Networking & Communication
Estimated reading: 3 minutes 25 views

πŸ” Linux/Unix: Transfers & Access – ssh, scp, rsync, sftp Explained with Examples

🧲 Introduction – Why Learn Secure Transfers & Access in Linux?

In Linux and Unix systems, remote access and file transfers are essential for system administration, backups, scripting, and DevOps. Tools like ssh, scp, rsync, and sftp enable you to connect securely, transfer data, and synchronize files over networksβ€”all encrypted via SSH.

🎯 In this guide, you’ll learn:

  • How to securely connect to remote machines using ssh
  • How to transfer files with scp, rsync, and sftp
  • The differences, use cases, and output of each tool

πŸ”‘ 1. ssh – Secure Remote Shell Access

βœ… What is ssh?

ssh (Secure Shell) allows you to log in to remote systems securely over an encrypted channel.

πŸ› οΈ Syntax:

ssh [user@]hostname [command]

πŸ§ͺ Example 1: Login to a remote machine

ssh user@192.168.1.100

πŸ“€ Output:

user@192.168.1.100's password:
Welcome to Ubuntu 22.04 LTS ...

πŸ§ͺ Example 2: Run a command remotely

ssh user@192.168.1.100 uptime

πŸ“€ Output:

 14:23:01 up 10 days,  5:12,  2 users,  load average: 0.15, 0.09, 0.05

πŸ“€ 2. scp – Secure Copy Over SSH

βœ… What is scp?

scp securely transfers files between local and remote systems using SSH.

πŸ› οΈ Syntax:

scp [options] source destination

πŸ§ͺ Example 1: Copy a file to remote server

scp file.txt user@192.168.1.100:/home/user/

πŸ§ͺ Example 2: Copy a remote file to local system

scp user@192.168.1.100:/var/log/syslog /tmp/

🧠 Common Flags:

FlagDescription
-rRecursive copy (for dirs)
-PUse custom port
-vVerbose output

πŸ” 3. rsync – Efficient Synchronization Tool

βœ… What is rsync?

rsync is used to synchronize files and directories between local and remote systems. It transfers only differences, making it fast and efficient.

πŸ› οΈ Syntax:

rsync [options] source destination

πŸ§ͺ Example 1: Sync local directory to remote

rsync -avz /etc/ user@192.168.1.100:/backup/etc/

πŸ“€ Output:

sending incremental file list
etc/
etc/passwd
etc/hostname
sent 4,095 bytes  received 82 bytes  total size 3,512

🧠 Common Flags:

FlagDescription
-aArchive (preserve all)
-vVerbose
-zCompress during transfer
--deleteDelete extra files on dest

🌐 4. sftp – Interactive File Transfer over SSH

βœ… What is sftp?

sftp provides an interactive shell to transfer files using the SSH File Transfer Protocol.

πŸ› οΈ Syntax:

sftp [user@]host

πŸ§ͺ Example 1: Start SFTP session

sftp user@192.168.1.100

πŸ“€ Output:

Connected to 192.168.1.100.
sftp>

πŸ§ͺ Example 2: Upload and download files

Inside sftp> shell:

put localfile.txt
get remotefile.log

🧠 Common SFTP Commands:

CommandDescription
lsList remote files
lcdChange local dir
cdChange remote dir
putUpload file
getDownload file
exitExit sftp shell

βš–οΈ Comparison Table: ssh vs scp vs rsync vs sftp

ToolPurposeSupports SSHInteractivityBest For
sshRemote command executionβœ…βŒLogin and shell commands
scpSecure file copyβœ…βŒSimple file transfers
rsyncEfficient file synchronizationβœ…βŒBackups and incremental syncs
sftpInteractive file transfersβœ…βœ…Manual uploads/downloads

πŸ“Œ Summary – Recap & Next Steps

These Linux tools make it easy to remotely access systems, transfer files securely, and sync data across environments. They’re built on SSH, ensuring encrypted communication.

πŸ” Key Takeaways:

  • Use ssh to log into remote systems or run remote commands
  • Use scp for quick file copying over SSH
  • Use rsync for efficient, repeatable file backups and sync
  • Use sftp for interactive file uploads/downloads

❓ FAQs

❓ Is scp faster than rsync?
❌ No. rsync is faster for large or repeat transfers due to delta-copying.

❓ Can I resume interrupted scp transfers?
❌ Not natively. Use rsync instead:

rsync --partial --progress file user@host:/path/

❓ How can I change ports in ssh, scp, or rsync?
βœ… Use -p for ssh/scp, and -e 'ssh -p PORT' for rsync.

❓ Which one supports GUI alternatives?
βœ… sftp can be used via GUI tools like FileZilla, WinSCP, or Cyberduck.

❓ Is it secure to use these tools over the internet?
βœ… Yes, if using SSH keys and disabling password authentication for added security.


Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

πŸ”΅ Linux/Unix: Transfers & Access (ssh, scp, rsync, sftp)

Or Copy Link

CONTENTS
Scroll to Top