ssh Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

The ssh command is a widely used command-line tool for securely connecting to a remote Linux system over the network. It uses encryption techniques to establish a secure communication channel between the local and remote system. This article will cover the syntax, options, and usage of the ssh command in Linux.

Linux ssh Command Syntax

The syntax for the ssh command is as follows:

Where:

  • user: The user name to use when logging in to the remote system.
  • hostname: The IP address or domain name of the remote system.
  • command: The command to execute on the remote system after logging in.

ssh Command Options:

  • -p: Specifies the port number to use for the connection.
  • -i: Specifies the identity file to use for authentication.
  • -l: Specifies the login name.
  • -t: Forces pseudo-tty allocation.
  • -C: Enables compression.
  • -X: Enables X11 forwarding.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Example Usages

  • Connect to a remote system using ssh:

    Output:

    Explanation: This command will prompt for the password of the user on the remote system to establish the connection.

  • Execute a command on a remote system using ssh:

    Explanation: This command will execute the specified command on the remote system after logging in.

  • Connect to a remote system using a non-default port:

    Output:

    Explanation: This command will use the specified port number for the connection instead of the default port (22).

  • Connect to a remote system using a specific identity file:

    Output:

    Explanation: This command will use the specified identity file for authentication instead of the default identity file.

  • Enable X11 forwarding:

    Output:

    Explanation: This command will enable X11 forwarding, which allows running GUI applications on the remote system and displaying them on the local system.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Tips

  • Use the -v option for verbose output, which can be helpful for debugging connection issues.

  • To avoid entering the password every time, consider using SSH key-based authentication instead of password authentication.

  • Make sure to configure the firewall rules on the remote system to allow incoming SSH traffic on the specified port number.

Advanced Use Cases of ssh Command in Linux

  • Copy files from local system to remote system using ssh:

    Explanation: This command uses the scp utility over ssh to securely copy files from the local system to the remote system.

  • Create a reverse tunnel using ssh:

    Explanation: This command creates a reverse tunnel, which allows a connection to be initiated from the remote system to the local system.

  • Mount a remote directory on the local system using sshfs:

    Explanation: This command uses sshfs to mount a remote directory on the local system, allowing access to the remote files as if they were local.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Conclusion

  • The ssh command is a powerful tool for securely connecting to remote Linux systems over the network.

  • It provides options for customizing the connection and executing remote commands.

  • The ssh command can be used in conjunction with other tools such as scp and sshfs to perform advanced tasks.

  • Proper configuration of the firewall and SSH key-based authentication can further enhance security when using ssh.