Denizhalil

SSH Commands and Usages Cheat Sheet

Introduction

SSH (Secure Shell) is a secure remote access protocol that enables encrypted communication between computers over a network. SSH is commonly used to securely connect to servers and other network devices, remotely execute commands, copy files, and perform other network management tasks. In this article, we will explain what SSH is and outline some basic SSH commands.

What is SSH?

SSH is a protocol that provides a secure connection between computers over a network. It ensures security by encrypting communication and securing the authentication processes, allowing users to securely transmit their passwords or other credentials.

SSH enables system administrators to manage servers and access remote devices securely. It can also be used for copying files, managing files, configuring security settings, and other network management tasks.

15 Different SSH Commands and Usages

  • Connect to Another Server:
ssh username@server_address

This command connects to the specified server via SSH.

  • Specify an Alternative SSH Port:
ssh -p PORT username@server_address

This command connects to the server via SSH using the specified port number.

  • SSH Key-Based Authentication:
ssh -i /path/to/key_file username@server_address

This command securely authenticates to the server via SSH using the specified private key file.

  • Copy File to Server:
scp file_address username@server_address:/remote/directory

This command copies a file from the local machine to the specified server.

  • Copy File to Local Machine:
scp username@server_address:/remote/file_address /local/directory

This command copies a file from the specified server to the local machine.

  • List Files/Directories on Remote Server:
ssh username@server_address 'ls /remote/directory'

This command lists files and directories on the specified server.

  • Run Command in Background:
ssh -f username@server_address 'command'

This command runs the specified command on the server in the background.

  • Run Command on Remote Server:
ssh username@server_address 'command'

This command runs the specified command on the server.

  • Run Command on Remote Server with sudo
ssh -t username@server_address 'sudo command'

This command runs the specified command with sudo privileges on the server.

  • Create SSH Tunnel (Port Forwarding):
ssh -L LOCAL_PORT:REMOTE_HOST:REMOTE_PORT username@server_address

This command creates a tunnel between a specific port on the local machine and a remote host on the server.

  • Compress and Copy File via SSH:
tar czf - file/directory | ssh username@server_address 'cd /destination/directory && tar xzf -'

This command compresses the specified file or directory and copies it to the remote server.

  • Work in a Specific Directory on Remote Server:
ssh -t username@server_address 'cd /destination/directory && bash'

This command connects to the specified directory via SSH and executes commands in that directory.

Secure Shell (SSH): Commands & Usage
SSH commands and usage
  • Compress and Accelerate SSH Sessions:
ssh -C username@server_address

This command accelerates communication by compressing SSH sessions.

  • Set Timeout for SSH Session:
ssh -o ConnectTimeout=10 username@server_address

This command sets a timeout for the SSH session.

  • Exit SSH Session:
exit

This command exits the SSH session.

Conclusion

SSH is a secure remote access protocol and a fundamental tool for network administrators. In this article, we have learned what SSH is and explored some basic SSH commands. We have seen that SSH can be used to securely connect to servers and other network devices, copy files, execute commands remotely, and perform other network management tasks. By learning these commands, you can efficiently perform your daily network management tasks.

1 thought on “SSH Commands and Usages Cheat Sheet”

  1. Wonderful web site Lots of useful info here Im sending it to a few friends ans additionally sharing in delicious And obviously thanks to your effort

    Reply

Leave a Comment

Join our Mailing list!

Get all latest news, exclusive deals and academy updates.