SSH commands let you connect to a Linux server securely and manage it from your computer. Whether you’re using a VPS, working with website files, or learning Linux administration, SSH is one of the first skills worth mastering.
The good news is that you don’t need to memorize dozens of commands. Once you understand how to connect to a server and navigate its filesystem, many everyday tasks become straightforward.
In this beginner-friendly SSH tutorial, you’ll learn how to establish your first connection, explore Linux directories, create files, and disconnect safely.
What Is SSH?
SSH (Secure Shell) is a network protocol that provides encrypted communication between your computer and a remote server.
Instead of accessing your server through a graphical control panel, SSH lets you manage it using a command-line interface called a terminal.
For example, you can use SSH to:
- Manage website files and directories.
- Install and update software.
- Check server resources and logs.
- Transfer files securely.
- Configure applications and services.
There’s an important difference to understand: SSH connects you to the server, while Linux commands perform tasks after you’re connected.
SSH is commonly used with Linux-based virtual private servers. If you’re unfamiliar with virtual servers, our What Is VPS Hosting? guide explains how they work.
What Do You Need Before Using SSH?
Before connecting, make sure you have:
- Server IP address: The address of your Linux server.
- SSH username: The account you’re authorized to access.
- Authentication credentials: A password or SSH private key.
- SSH port: Usually port 22, unless configured differently.
- SSH client: A terminal application capable of establishing SSH connections.
Linux and macOS include SSH command-line tools. Windows 10 and 11 also support OpenSSH through PowerShell or Windows Terminal when the client is installed.
Your server must have an SSH service running and allow connections from your network.
How to Connect to a Linux Server Using SSH
Open Terminal, PowerShell, or Windows Terminal on your computer.
Enter the following command:
ssh username@203.0.113.10
Replace username with your Linux account name and 203.0.113.10 with your server’s actual IP address.
For example, if your server username is admin, the command becomes:
ssh admin@203.0.113.10
If your server uses a custom SSH port, such as 2222, connect using:
ssh -p 2222 admin@203.0.113.10
When connecting to an unfamiliar server for the first time, SSH may display its host-key fingerprint and ask whether you trust it. Verify the fingerprint through your hosting provider or another trusted source before accepting it.
After authentication, you’ll see a Linux command prompt similar to:
admin@server:~$
Congratulations! You’re now connected to your Linux server.
The commands you enter at this prompt will run on the remote server, not your personal computer.
Understanding the Linux Terminal
Before running commands, let’s understand what the terminal displays.
Consider this example:
admin@server:~$
adminrepresents your current username.serveridentifies the computer you’re connected to.~represents your home directory.$commonly indicates a regular user’s shell prompt.
Your prompt may look different depending on the Linux distribution and shell configuration.
Now you’re ready to try your first commands.
Your First SSH Commands: A Hands-On Exercise
Rather than memorizing commands individually, let’s complete a simple exercise.
We’ll identify your current location, create a directory, add a text file, and display its contents.
All the changes will take place inside your own home directory.

Step 1: Check Your Username and Location
Start with:
whoami
This displays the username associated with your current session.
Next, run:
pwd
The pwd command means print working directory. It shows your current location in the filesystem.
For example, you might see:
/home/admin
This means you’re currently working inside the home directory belonging to the admin user.
Step 2: List Files and Directories
Use:
ls -la
This displays files and folders in your current directory, including hidden entries.
The -l option provides detailed information, while -a includes hidden files.
You’ll frequently use ls when browsing directories or checking whether files exist.
Step 3: Create a New Directory
Let’s create a folder for this exercise.
mkdir ~/ssh-practice
The mkdir command creates directories. Here, we’re creating one named ssh-practice in your home folder.
Move into it using:
cd ~/ssh-practice
Now run:
pwd
Your terminal should display a path similar to:
/home/admin/ssh-practice
The cd command stands for change directory. You can use cd .. to move to the parent directory or cd ~ to return home.
Step 4: Create Your First File
Now create an empty text file:
touch hello.txt
The touch command creates the file if it doesn’t already exist. If it does exist, the command updates its timestamps.
Check the directory contents:
ls -l
You should see hello.txt listed.
Let’s add some text:
printf 'Hello from Linux!\n' > hello.txt
The printf command produces the text, while > writes the output to the file.
Be careful: the > operator overwrites the destination file’s existing content.
To display what you’ve written, run:
cat hello.txt
You should see:
Hello from Linux!
You’ve now created a directory, moved into it, written a file, and displayed its contents—all through SSH.
Step 5: Disconnect Safely
When you’ve finished working, enter:
exit
This closes your remote shell session and returns you to your local terminal.
You don’t need to shut down or restart your VPS when disconnecting. The server continues running normally.
How to Transfer Files Using SSH
SSH can also transfer files securely between your computer and server.
One straightforward option is scp (secure copy).
For example, to upload a file from your computer into the practice directory, run this command in your local terminal, not inside the SSH session:
scp ./example.txt admin@203.0.113.10:~/ssh-practice/
Replace the username and IP address with your own details. The local file example.txt must already exist.
To download a file from your server:
scp admin@203.0.113.10:~/ssh-practice/hello.txt ./
This saves a copy of hello.txt in your current local directory.
For interactive file transfers, you can also use SFTP, which operates over an SSH connection.
Understanding SSH Keys
SSH supports password authentication and public-key authentication.
With SSH keys, you create two related keys:
- Public key: Installed on the server to authorize access.
- Private key: Kept securely on your computer.
The private key should never be shared.
You can generate an Ed25519 key pair using:
ssh-keygen -t ed25519
Follow the prompts and choose a strong passphrase.
On Linux or macOS, if your server allows an existing login method and ssh-copy-id is installed, you can add the public key using:
ssh-copy-id admin@203.0.113.10
Some VPS providers also allow public keys to be configured through their control panels.
Test your new key-based login before making changes to password authentication.
For beginners, the most important lesson is simple: protect your private key, verify server identities, and never disable an authentication method until you know the replacement works.
Common SSH Connection Errors
SSH connections occasionally fail. Understanding the error message helps identify the problem.
| Error | Possible Cause |
|---|---|
| Connection timed out | Network routing, firewall, or unreachable server |
| Connection refused | SSH service isn’t listening on the specified port |
| Permission denied (publickey) | Incorrect username, SSH key, or server permissions |
| Host key verification failed | The server’s identity doesn’t match the saved key |
If you encounter a connection problem, verify your IP address, username, port, and credentials.
For authentication issues, check that you’re using the correct private key and that its corresponding public key is authorized on the server.
Don’t disable SSH host-key verification to bypass an unexpected warning. Verify the server’s identity first.
Essential SSH Security Tips
Before managing production servers, follow a few basic security practices:
- Use SSH keys with strong passphrases when supported.
- Protect your private keys and login credentials.
- Keep your operating system and SSH software updated.
- Avoid logging in directly as root unless necessary.
- Restrict SSH access using appropriate firewall rules.
- Keep an alternative recovery method available before changing SSH settings.
SSH provides encrypted communication, but your server still requires proper maintenance and access management.
What Should You Learn After SSH?
Once you’re comfortable connecting to Linux and navigating directories, you can gradually expand your skills.
A useful learning order is:
- Linux file management: Learn to copy, move, rename, and inspect files.
- File permissions: Understand
chmod,chown, and administrative privileges. - Software management: Install and update packages using APT or DNF.
- Service management: Start, stop, and inspect services using
systemctl. - Server monitoring: Check memory, disk usage, and system logs.
These skills will make it easier to manage websites, troubleshoot applications, and maintain Linux servers confidently.
Ready to go beyond basic SSH tasks? Explore our guide to essential Linux commands for server management to learn how to monitor resources, manage services, and troubleshoot common server problems.
Once you’re comfortable using SSH, you can begin troubleshooting web server problems directly from the terminal. Our guide to fixing 502 Bad Gateway in Nginx and how to fix 504 Gateway Timeout errors shows you how to inspect error logs, check backend services, and diagnose common server failures.
Frequently Asked Questions
SSH commands are used to connect to remote systems, execute commands, and transfer files securely. After connecting, you can use Linux shell commands to manage files, software, and server services.
Yes. Windows 10 and 11 support OpenSSH, which can be used through PowerShell or Windows Terminal when installed.
No. SSH can connect to regular user accounts. Some administrative operations require elevated privileges, but everyday file management and navigation usually don’t.
Yes, provided you understand the commands you execute and follow basic security practices. Start with harmless file and directory operations before attempting system-level changes.
Conclusion
SSH is an essential skill for anyone learning Linux server administration. It provides a secure way to access remote systems, manage files, transfer data, and perform everyday maintenance.
The best way to learn SSH commands is through practice. Start with connecting to your server, navigating directories, and creating files before moving on to more advanced administration tasks.
Once you’re comfortable with your first SSH session, you’ll have the foundation needed for almost every other Linux server tutorial.