ssh Command in Linux
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
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.
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
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
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
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.




