WE CODE NOW
  • Home 
  • Blog 
  • Guides 
Guides
  1. Home
  2. Guides
  3. Linux Command Series
  4. Linux Networking: SSH and SCP

Linux Networking: SSH and SCP

Posted on June 1, 2024  (Last modified on June 8, 2024) • 2 min read • 280 words
Linux
 
Ssh
 
Scp
 
Remote Access
 
File Transfers
 
Linux
 
Ssh
 
Scp
 
Remote Access
 
File Transfers
 
Share via

Master SSH and SCP commands in Linux for secure remote access and file transfers, including key-based authentication and managing SSH sessions.

On this page
  • SSH Configuration
    • Installing SSH
    • Configuring SSH
  • Key-Based Authentication
    • Generating SSH Keys
    • Copying SSH Keys to the Remote Server
    • Connecting with SSH Keys
  • Managing SSH Sessions
    • Using tmux
    • Using screen
  • File Transfers with SCP
    • Basic File Transfer
    • Recursive File Transfer
    • Transferring Files Between Remote Systems
  • Conclusion

Linux Networking: SSH and SCP  

SSH and SCP are essential tools for secure remote access and file transfers in Linux. This guide covers SSH configuration, key-based authentication, and using SCP for file transfers.

SSH Configuration  

Installing SSH  

Install the OpenSSH server.

sudo apt-get install openssh-server

Start and enable the SSH service.

sudo systemctl start ssh
sudo systemctl enable ssh

Configuring SSH  

Edit the SSH configuration file.

sudo vim /etc/ssh/sshd_config

Restart the SSH service to apply changes.

sudo systemctl restart ssh

Key-Based Authentication  

Generating SSH Keys  

Generate a new SSH key pair.

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Copying SSH Keys to the Remote Server  

Use ssh-copy-id to copy your public key to the remote server.

ssh-copy-id user@remote_server

Connecting with SSH Keys  

Connect to the remote server using key-based authentication.

ssh user@remote_server

Managing SSH Sessions  

Using tmux  

Use tmux to manage SSH sessions.

tmux new -s session_name

Detach from the session.

Ctrl-b d

Reattach to the session.

tmux attach -t session_name

Using screen  

Use screen to manage SSH sessions.

screen -S session_name

Detach from the session.

Ctrl-a d

Reattach to the session.

screen -r session_name

File Transfers with SCP  

Basic File Transfer  

Use scp to copy files between local and remote systems.

scp local_file user@remote_server:/path/to/destination

Recursive File Transfer  

Use -r option to transfer directories.

scp -r local_directory user@remote_server:/path/to/destination

Transferring Files Between Remote Systems  

Use scp to transfer files between two remote systems.

scp user1@remote1:/path/to/file user2@remote2:/path/to/destination

Conclusion  

Mastering SSH and SCP commands is essential for secure remote access and file transfers in Linux. Practice configuring SSH, setting up key-based authentication, and using SCP for file transfers to enhance your networking skills.

 Linux System Logging and Log Management
Docker Basics in Linux 
On this page:
  • SSH Configuration
    • Installing SSH
    • Configuring SSH
  • Key-Based Authentication
    • Generating SSH Keys
    • Copying SSH Keys to the Remote Server
    • Connecting with SSH Keys
  • Managing SSH Sessions
    • Using tmux
    • Using screen
  • File Transfers with SCP
    • Basic File Transfer
    • Recursive File Transfer
    • Transferring Files Between Remote Systems
  • Conclusion
Copyright © 2025 WE CODE NOW All rights reserved.
WE CODE NOW
Link copied to clipboard
WE CODE NOW
Code copied to clipboard