âšď¸ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server |
| Last Crawled | 2026-04-16 09:52:54 (1 day ago) |
| First Indexed | 2020-11-13 01:06:56 (5 years ago) |
| HTTP Status Code | 200 |
| Meta Title | How to Use SSH to Connect to a Remote Server (Step-by-Step Guide) | DigitalOcean |
| Meta Description | Learn how to use SSH to securely connect to a remote server. This step-by-step guide covers setup, syntax, key auth, troubleshooting, and best practices. |
| Meta Canonical | null |
| Boilerpipe Text | Introduction
One essential tool to master as a system administrator is SSH.
SSH, or
Secure Shell
, is a protocol used to securely log onto remote systems. It is the most common way to access remote Linux servers.
In this guide, we will discuss how to use SSH to connect to a remote system.
Deploy your frontend applications from GitHub using
DigitalOcean App Platform
. Let DigitalOcean focus on scaling your app.
Quick Start: How to SSH into a Remote Server in 5 Steps
Open your terminal.
On
Linux/macOS
: Launch the Terminal app.
On
Windows
: Use PowerShell, Git Bash, or WSL.
Run the SSH command:
ssh
username@your_server_ip
Review and accept the host fingerprint
if prompted.
Authenticate
using your password or an SSH key (if configured).
Youâre connected!
Type
exit
to close the SSH session and return to your local shell.
Successful SSH connection using Termius, showing Ubuntu welcome screen and shell prompt
Core Syntax
To connect to a remote system using SSH, weâll use the
ssh
command.
If you are using Windows, youâll need to install a version of OpenSSH in order to be able to
ssh
from a terminal. If you prefer to work in PowerShell, you can follow
Microsoftâs documentation
to add OpenSSH to PowerShell. If you would rather have a full Linux environment available, you can
set up WSL
, the Windows Subsystem for Linux, which will include
ssh
by default. Finally, as a lightweight third option, you can install
Git for Windows
, which provides a native Windows bash terminal environment that includes the
ssh
command. Each of these are well-supported and whichever you decide to use will come down to preference.
If you are using a Mac or Linux, you will already have the
ssh
command available in your terminal.
The most straightforward form of the command is:
ssh
remote_host
The
remote_host
in this example is the IP address or domain name that you are trying to connect to.
This command assumes that your username on the remote system is the same as your username on your local system.
If your username is different on the remote system, you can specify it by using this syntax:
ssh
remote_username@remote_host
Once you have connected to the server, you may be asked to verify your identity by providing a password. Later, we will cover how to generate keys to use instead of passwords.
To exit the ssh session and return back into your local shell session, type:
exit
How Does SSH Work?
SSH works by connecting a client program to an
ssh server
, called
sshd
.
In the previous section,
ssh
was the client program. The
ssh server
was already running on the
remote_host
that we specified.
On nearly all Linux environments, the
sshd
server should start automatically. If it is not running for any reason, you may need to temporarily access your server through a web-based console or local serial console.
The process needed to start an ssh server depends on the distribution of Linux that you are using.
On Ubuntu, you can start the ssh server by typing:
sudo
systemctl start
ssh
That should start the sshd server, and you can then log in remotely.
As a bonus, if youâre using DigitalOcean, you donât necessarily need an SSH client at all. DigitalOcean provides a built-in
Console
feature for each Droplet. This browser-based terminal lets you access your server even if your SSH client is misconfigured or unavailable. Itâs especially helpful for first-time users or emergency access, keeping you fully within the DigitalOcean ecosystem without relying on third-party tools.
Access your server through DigitalOceanâs browser-based Console, ideal for emergency access without an SSH client.
For a more detailed explanation of how SSH servers and clients interact, check out
SSH Essentials: Working with SSH Servers, Clients, and Keys
.
How To Configure SSH
When you change the configuration of SSH, you are changing the settings of the
sshd
server.
In Ubuntu, the main
sshd
configuration file is located at
/etc/ssh/sshd_config
.
Back up the current version of this file before editing:
sudo
cp
/etc/ssh/sshd_config
{
,.bak
}
Open it using
nano
or your favorite text editor:
sudo
nano
/etc/ssh/sshd_config
You will want to leave most of the options in this file alone. However, there are a few you may want to take a look at:
/etc/ssh/sshd_config
Port
22
The port declaration specifies which port the
sshd
server will listen on for connections. By default, this is
22
. You should probably leave this setting alone unless you have specific reasons to do otherwise. If you
do
change your port, we will show you how to connect to the new port later on.
/etc/ssh/sshd_config
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
The host key declarations specify where to look for global host keys. We will discuss what a host key is later.
/etc/ssh/sshd_config
SyslogFacility AUTH
LogLevel INFO
These two items indicate the level of logging that should occur.
If you are having difficulties with SSH, increasing the amount of logging may be a good way to discover what the issue is.
/etc/ssh/sshd_config
LoginGraceTime
120
PermitRootLogin
yes
StrictModes
yes
These parameters specify some of the login information.
LoginGraceTime
specifies how many seconds to keep the connection alive without successfully logging in.
It may be a good idea to set this time just a little bit higher than the amount of time it takes you to log in normally.
PermitRootLogin
selects whether the
root
user is allowed to log in.
In most cases, this should be changed to
no
when you have created a user account that has access to elevated privileges (through
su
or
sudo
) and can log in through SSH in order to minimize the risk of anyone gaining root access to your server.
strictModes
is a safety guard that will refuse a login attempt if the authentication files are readable by everyone.
This prevents login attempts when the configuration files are not secure.
/etc/ssh/sshd_config
X11Forwarding
yes
X11DisplayOffset
10
These parameters configure an ability called
X11 Forwarding
. This allows you to view a remote systemâs graphical user interface (GUI) on the local system.
This option must be enabled on the server and given to the SSH client during connection with the
-X
option.
After making your changes, save and close the file. If you are using
nano
, press
Ctrl+X
, then when prompted,
Y
and then Enter.
If you changed any settings in
/etc/ssh/sshd_config
, make sure you reload your
sshd
server to implement your modifications:
sudo
systemctl reload
ssh
You should thoroughly test your changes to ensure that they operate in the way you expect.
It may be a good idea to have a few terminal sessions open while you are making changes. This will allow you to revert the configuration if necessary without locking yourself out.
How To Use
~/.ssh/config
for Multiple SSH Connections
To simplify access to multiple servers, create or edit
~/.ssh/config
:
Host dev-server
HostName
192.168
.1.10
User devuser
Port
2222
IdentityFile ~/.ssh/dev_key
Then connect using:
ssh
dev-server
This is useful if you manage multiple SSH keys and nonstandard ports.
How To Log Into SSH with Keys
While it is helpful to be able to log in to a remote system using passwords, it is faster and more secure to set up
key-based authentication
.
How Does Key-based Authentication Work?
Key-based authentication works by creating a pair of keys: a
private key
and a
public key
.
The
private key
is located on the clientâs machine and is secured and kept secret.
The
public key
can be given to anyone or placed on any server you wish to access.
When you attempt to connect using a key pair, the server will use the public key to create a message for the client computer that can only be read with the private key.
The client computer then sends the appropriate response back to the server, which will tell the server that the client is legitimate.
This process is performed automatically after you configure your keys.
To dive deeper into the mechanics behind SSH encryption and how the connection process works, read
Understanding the SSH Encryption and Connection Process
.
How To Create SSH Keys
SSH keys should be generated on the computer you wish to log in
from
. This is usually your local machine.
Enter the following into the command line:
ssh-keygen
-t
rsa
You may be prompted to set a password on the key files themselves, but this is a fairly uncommon practice, and you should press enter through the prompts to accept the defaults. Your keys will be created at
~/.ssh/id_rsa.pub
and
~/.ssh/id_rsa
.
For a comprehensive walkthrough on configuring SSH key-based access, see
How to Configure SSH Key-Based Authentication on a Linux Server
.
Change into the
.ssh
directory by typing:
cd
~/.ssh
Look at the permissions of the files:
ls
-l
Output
-rw-r--r--
1
demo demo
807
Sep
9
22
:15 authorized_keys
-rw-------
1
demo demo
1679
Sep
9
23
:13 id_rsa
-rw-r--r--
1
demo demo
396
Sep
9
23
:13 id_rsa.pub
As you can see, the
id_rsa
file is readable and writable only to the owner. This helps to keep it secret.
The
id_rsa.pub
file, however, can be shared and has permissions appropriate for this activity.
How To Transfer Your Public Key to the Server
If you currently have password-based access to a server, you can copy your public key to it by issuing this command:
ssh-copy-id
remote_host
This will start an SSH session. After you enter your password, it will copy your public key to the serverâs authorized keys file, which will allow you to log in without the password next time.
Client-Side Options
There are a number of optional flags that you can provide when connecting through SSH.
Some of these may be necessary to match the settings in the remote hostâs
sshd
configuration.
For instance, if you changed the port number in your
sshd
configuration, you will need to match that port on the client side by typing:
ssh
-p
port_number
remote_host
Note:
Changing your ssh port is a reasonable way of providing
security through obscurity
. If you are allowing SSH connections to a widely known server deployment on port
22
as normal and you have password authentication enabled, you will likely be attacked by many automated login attempts. Exclusively using key-based authentication and running SSH on a nonstandard port is not the most complex security solution you can employ, but you should reduce these to a minimum.
If you only want to execute a single command on a remote system, you can specify it after the host like so:
ssh
remote_host
command_to_run
You will connect to the remote machine, authenticate, and the command will be executed.
As we said before, if X11 forwarding is enabled on both computers, you can access that functionality by typing:
ssh
-X
remote_host
Providing you have the appropriate tools on your computer, GUI programs that you use on the remote system will now open their window on your local system.
Common SSH Errors and Troubleshooting Tips
Error
Possible Cause
Recommended Solution
SSH Connection Refused
SSH service (
sshd
) not running or port blocked
Start SSH:
sudo systemctl start ssh
; check firewall rules
Permission Denied (Publickey)
Incorrect file permissions or missing public key
Fix permissions:
chmod 700 ~/.ssh
,
chmod 600 ~/.ssh/authorized_keys
SSH Timeout or Hang
DNS issue, unreachable host, or blocked port
Use verbose debug:
ssh -vvv user@host
; check network/firewall
Advanced SSH Errors and Troubleshooting Tips
Error
Possible Cause
Advanced Solution
Host key verification failed
Mismatch in
known_hosts
file due to IP/host change
Remove old key:
ssh-keygen -R server_ip
; or edit
~/.ssh/known_hosts
manually
Too many authentication failures
Too many keys attempted by SSH agent
Force identity:
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_rsa user@host
Connection closed by remote host
Idle timeout or restricted config on remote server
Check
sshd_config
for
ClientAliveInterval
,
MaxAuthTries
, or login limits
Bad owner or permissions on .ssh
Loose file permissions pose a security risk
Ensure:
chmod 700 ~/.ssh
,
chmod 600 ~/.ssh/id_rsa
,
chmod 644 ~/.ssh/id_rsa.pub
Cannot resolve hostname
Typo in hostname or DNS failure
Verify DNS, correct typos, or edit
/etc/hosts
for static resolution
Authentication refused: no methods available
Both password and key-based auth disabled on server
Ensure keys are installed or enable one method in
/etc/ssh/sshd_config
Disabling Password Authentication
If you have created SSH keys, you can enhance your serverâs security by disabling password-only authentication. Apart from the console, the only way to log into your server will be through the private key that pairs with the public key you have installed on the server.
Warning:
Before you proceed with this step, be sure you have installed a public key to your server. Otherwise, you will be locked out!
As
root
or user with sudo privileges, open the
sshd
configuration file:
sudo
nano
/etc/ssh/sshd_config
Locate the line that reads
Password Authentication
, and uncomment it by removing the leading
#
. You can then change its value to
no
:
/etc/ssh/sshd_config
PasswordAuthentication no
Two more settings that should not need to be modified (provided you have not modified this file before) are
PubkeyAuthentication
and
ChallengeResponseAuthentication
. They are set by default and should read as follows:
/etc/ssh/sshd_config
PubkeyAuthentication
yes
ChallengeResponseAuthentication no
After making your changes, save and close the file.
You can now reload the SSH daemon:
sudo
systemctl reload
ssh
Password authentication should now be disabled, and your server should be accessible only through SSH key authentication.
SSH Security Best Practices Checklist
Disable password authentication (
PasswordAuthentication no
)
Change default port from 22 to something else
Use SSH keys instead of passwords
Set
PermitRootLogin no
Enable automatic security updates
Restrict SSH access via firewall (e.g., UFW or firewalld)
How to SSH on Windows, Linux, and macOS
Windows:
Use PowerShell, Git Bash, or WSL to access SSH.
Example:
ssh
user@server_ip
macOS/Linux:
Use the built-in terminal and the same command.
Generate keys using:
ssh-keygen
Frequently Asked Questions (FAQs)
Q: What is SSH used for?
SSH, or Secure Shell
, is primarily used to securely log into remote systems, typically Linux-based servers. It creates an encrypted channel over an unsecured network, allowing you to execute commands, transfer files, and manage infrastructure securely. SSH is critical for system administrators, developers, and DevOps teams to remotely access virtual machines (like DigitalOcean Droplets), automate tasks with scripts, and even forward ports or tunnel traffic through secure connections for added protection and control.
Q: How do I generate SSH keys?
SSH keys are generated using the
ssh-keygen
utility, which creates a secure public-private key pair. Run
ssh-keygen -t rsa -b 4096
to create strong RSA keys. The private key remains on your local machine, typically stored in
~/.ssh/id_rsa
, while the public key (
id_rsa.pub
) is placed on the remote server. When connecting, the server uses the public key to verify your identity without transmitting passwords. Key-based authentication enhances both security and automation for server access.
Q: What does âPermission deniedâ mean in SSH?
The âPermission deniedâ error in SSH usually indicates an authentication failure. This may be caused by incorrect usernames, expired or improperly set permissions on your
.ssh
directory or key files, or missing public keys on the remote server. SSH requires the
~/.ssh
directory to have
700
permissions and private keys like
id_rsa
to have
600
. It could also mean that the SSH server disallows password authentication or root login, depending on how
sshd_config
is set.
Q: Is SSH safe to use?
Yes, SSH is considered one of the most secure methods for accessing remote systems. It uses asymmetric encryption and modern cryptographic algorithms to ensure confidentiality and data integrity. Security can be improved by disabling password authentication, using key pairs, changing the default port, enabling two-factor authentication (2FA), and using tools like Fail2Ban to prevent brute-force attempts. Regularly updating the SSH server and auditing logs also helps mitigate vulnerabilities and unauthorized access.
Q: Can I use SSH on Windows?
Absolutely. Windows now supports SSH natively through PowerShell and OpenSSH, especially in Windows 10 and later. You can also use Git Bash, which includes an SSH client, or enable the Windows Subsystem for Linux (WSL) for a full Linux environment. Each method allows you to use the
ssh
command to connect to servers. Generating SSH keys and configuring SSH access works similarly to Linux/macOS, making Windows a viable platform for remote system management via SSH.
Conclusion
Learning your way around SSH will greatly benefit any of your future cloud computing endeavors. As you use the various options, you will discover more advanced functionality that can make your life easier. SSH has remained popular because it is secure, lightweight, and useful in diverse situations.
To deepen your SSH knowledge, you can refer to these additional resources:
SSH Essentials: Working with SSH Servers, Clients, and Keys
for a comprehensive guide on SSH fundamentals
Understanding the SSH Encryption and Connection Process
to learn about SSHâs security mechanisms
How to Configure SSH Key-Based Authentication on a Linux Server
for enhanced security practices
Working with SFTP
to perform command line file transfers.
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License. |
| Markdown | [DigitalOcean acquires Katanemo Labs, Inc. to accelerate AI development](https://www.digitalocean.com/blog/digitalocean-acquires-katanemo-labs-inc)
[Now Available: Cloud Security Posture Management (CSPM)](https://www.digitalocean.com/blog/now-available-cloud-security-posture-management)
[Now Available: OpenAI GPT-5.4 on the Gradient⢠AI Platform](https://www.digitalocean.com/blog/whats-new-on-gradient-ai-platform#week-of-march-2)
[Now Available: OpenAI GPT-5.3 Codex on the Gradient⢠AI Platform](https://www.digitalocean.com/blog/whats-new-on-gradient-ai-platform#week-of-february-23rd)
[Now Available: Claude Sonnet 4.6 on the Gradient⢠AI Platform](https://www.digitalocean.com/blog/whats-new-on-gradient-ai-platform#week-of-february-17th)
[Join us for Deploy in San Francisco, on April 28, 2026. Register now](https://www.digitalocean.com/deploy)
- [Blog](https://www.digitalocean.com/blog)
- [Docs](https://docs.digitalocean.com/products)
- [Careers](https://www.digitalocean.com/careers)
- [Get Support](https://www.digitalocean.com/support)
- [Contact Sales](https://www.digitalocean.com/company/contact/sales?referrer=tophat)
[DigitalOcean](https://www.digitalocean.com/)
- Products
Featured Products
Gradient⢠AI Agentic Inference Cloud
Build, train, deploy apps/agents and scale at will
Compute
Build, deploy, and scale cloud compute resources
Containers and Images
Safely store and manage containers and backups
Managed Databases
Fully managed resources running popular database engines
Management and Dev Tools
Control infrastructure and gather insights
Networking
Secure and control traffic to apps
Security
Store and access any amount of data reliably in the cloud
Storage
Store and access any amount of data reliably in the cloud
[Browse all products](https://www.digitalocean.com/products)
### Featured Products
[Gradient⢠AI Agentic Cloud Build, train, deploy apps/agents and scale at will](https://www.digitalocean.com/products/gradient)
[Droplets Reliable, powerful, Linux-based virtual machines New updates](https://www.digitalocean.com/products/droplets)
[Managed Databases Fully managed resources running popular database engines](https://www.digitalocean.com/products/managed-databases)
[App Platform Publish code directly to DigitalOcean servers](https://www.digitalocean.com/products/app-platform)
[Gradient⢠AI GPU Droplets GPU-powered virtual machines to build and run AI apps](https://www.digitalocean.com/products/gradient/gpu-droplets)
[Kubernetes Fully managed, highly available K8s with autoscale.](https://www.digitalocean.com/products/kubernetes)
[Browse all products](https://www.digitalocean.com/products)
- Solutions
AI/ML
CMS
Data and IoT
Developer Tools
Gaming and Media
GPU
Hosting
Security and Networking
Startups and SMBs
Web and App Platforms
[See all solutions](https://www.digitalocean.com/solutions)
### AI/ML
[AI HR Knowledge Assistant Deploy AI tools developed for Human Resources](https://www.digitalocean.com/solutions/ai-hr-knowledge-assistant)
[AI Code Copilot Write, complete, and review code faster](https://www.digitalocean.com/solutions/ai-code-copilot)
[AI Support Ticket Triage Auto-classify and route customer support tickets](https://www.digitalocean.com/solutions/ai-support-ticket-triage)
[AI Recommendation Engine Build tools to personalize user experiences](https://www.digitalocean.com/solutions/ai-recommendation-engine)
[AI Agent Builder Create, deploy, and manage AI agents for anything](https://www.digitalocean.com/solutions/ai-agent-builder)
[Multimodal AI Run models that process multiple data types](https://www.digitalocean.com/solutions/multimodal-ai)
[Low-Latency Inference Run AI models quickly and efficiently](https://www.digitalocean.com/solutions/low-latency-inference)
Not seeing what you are looking for?
[Browse all AI/ML solutions](https://www.digitalocean.com/solutions)
[Need help? Talk to an expert](https://www.digitalocean.com/company/contact/sales?referrer=mainmenu/solutions)
[Get migration assistance](https://www.digitalocean.com/migrate)
- Developers
Community
Documentation
Developer Tools
Get Involved
Utilities and Help
### Community
[Blog The latest product releases and insights from our experts](https://www.digitalocean.com/blog)
[CSS Tricks All things web design](https://css-tricks.com/)
[The Wave Content to level up your business](https://www.digitalocean.com/resources)
[Tutorials Our extensive library of technical articles](https://www.digitalocean.com/community/tutorials)
[Q\&A Answers to your cloud and coding questions](https://www.digitalocean.com/community/questions)
[YouTube Educational content and tutorials](https://youtube.com/DigitalOcean)
[Visit DigitalOcean's Community Site](https://www.digitalocean.com/community)
- Partners
Become a Partner
Marketplace
### Become a Partner
[About Partner Pod Discounts, revenue share, and more for businesses](https://www.digitalocean.com/partners/pod)
[AI Partner Program Boost your AI business](https://www.digitalocean.com/partners/ai-partner-program)
[DigitalOcean Startups Resources and support to propel your startup](https://www.digitalocean.com/startups)
[Partners Directory Current list of DigitalOcean Partners](https://www.digitalocean.com/partners/directory)
[Customer Stories Customers growing on DigitalOcean](https://www.digitalocean.com/customers)
[Need help? Talk to an expert](https://www.digitalocean.com/company/contact/sales?referrer=mainmenu/partners)
[Become a Partner](https://www.digitalocean.com/partners/apply)
- [Pricing](https://www.digitalocean.com/pricing)
- Log in
- [Community](https://www.digitalocean.com/api/dynamic-content/v1/login?success_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fcommunity%2Ftutorials%2Fhow-to-use-ssh-to-connect-to-a-remote-server&error_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fauth-error&type=login)
- [DigitalOcean](https://cloud.digitalocean.com/login)
- Sign up
- [Community](https://www.digitalocean.com/api/dynamic-content/v1/login?success_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fcommunity%2Ftutorials%2Fhow-to-use-ssh-to-connect-to-a-remote-server&error_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fauth-error&type=register)
- [DigitalOcean](https://cloud.digitalocean.com/registrations/new)
- Log in
- [Community](https://www.digitalocean.com/api/dynamic-content/v1/login?success_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fcommunity%2Ftutorials%2Fhow-to-use-ssh-to-connect-to-a-remote-server&error_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fauth-error&type=login)
- [DigitalOcean](https://cloud.digitalocean.com/login)
- Sign up
- [Community](https://www.digitalocean.com/api/dynamic-content/v1/login?success_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fcommunity%2Ftutorials%2Fhow-to-use-ssh-to-connect-to-a-remote-server&error_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fauth-error&type=register)
- [DigitalOcean](https://cloud.digitalocean.com/registrations/new)
- [Tutorials](https://www.digitalocean.com/community/tutorials)
- [Questions](https://www.digitalocean.com/community/questions)
- [Product Docs](https://docs.digitalocean.com/)
- Search Community
## Report this
What is the reason for this report?
This undefined is spam
This undefined is offensive
This undefined is off-topic
This undefined is other
Submit
## Table of contents
1. [Quick Start How to SSH into a Remote Server in 5 Steps](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#quick-start-how-to-ssh-into-a-remote-server-in-5-steps)
2. [Core Syntax](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#core-syntax)
3. [How Does SSH Work](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-does-ssh-work)
4. [How To Configure SSH](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-configure-ssh)
5. [How To Use sshconfig for Multiple SSH Connections](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-use-ssh-config-for-multiple-ssh-connections)
6. [How To Log Into SSH with Keys](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-log-into-ssh-with-keys)
7. [ClientSide Options](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#client-side-options)
8. [Common SSH Errors and Troubleshooting Tips](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#common-ssh-errors-and-troubleshooting-tips)
9. [Advanced SSH Errors and Troubleshooting Tips](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#advanced-ssh-errors-and-troubleshooting-tips)
10. [Disabling Password Authentication](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#disabling-password-authentication)
11. [SSH Security Best Practices Checklist](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#ssh-security-best-practices-checklist)
12. [How to SSH on Windows Linux and macOS](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-ssh-on-windows-linux-and-macos)
13. [Frequently Asked Questions FAQs](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#frequently-asked-questions-faqs)
14. [Conclusion](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#conclusion)
1. [Tutorials](https://www.digitalocean.com/community/tutorials?subtype=tutorial)
2. [Security](https://www.digitalocean.com/community/tags/security)
3. How to Use SSH to Connect to a Remote Server (Step-by-Step Guide)
[Tutorial](https://www.digitalocean.com/community/tutorials?subtype=tutorial)
# How to Use SSH to Connect to a Remote Server (Step-by-Step Guide)
Updated on June 6, 2025
[Linux Basics](https://www.digitalocean.com/community/tags/linux-basics)
[Security](https://www.digitalocean.com/community/tags/security)
[Ubuntu](https://www.digitalocean.com/community/tags/ubuntu)
[Networking](https://www.digitalocean.com/community/tags/networking)
[System Tools](https://www.digitalocean.com/community/tags/system-tools)

By [Justin Ellingwood](https://www.digitalocean.com/community/users/jellingwood), [Anish Singh Walia](https://www.digitalocean.com/community/users/asinghwalia) and [Vinayak Baranwal](https://www.digitalocean.com/community/users/vinayakbaranwal)
Language
English

Table of contents
Popular topics
### [Introduction](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#introduction)
One essential tool to master as a system administrator is SSH.
[SSH, or *Secure Shell*](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys), is a protocol used to securely log onto remote systems. It is the most common way to access remote Linux servers.
In this guide, we will discuss how to use SSH to connect to a remote system.
Deploy your frontend applications from GitHub using [DigitalOcean App Platform](https://www.digitalocean.com/products/app-platform). Let DigitalOcean focus on scaling your app.
## [Quick Start: How to SSH into a Remote Server in 5 Steps](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#quick-start-how-to-ssh-into-a-remote-server-in-5-steps)
1. **Open your terminal.**
- On **Linux/macOS**: Launch the Terminal app.
- On **Windows**: Use PowerShell, Git Bash, or WSL.
2. **Run the SSH command:**
```
ssh username@your_server_ip
```
Copy
3. **Review and accept the host fingerprint** if prompted.
4. **Authenticate** using your password or an SSH key (if configured).
5. **Youâre connected\!**
Type `exit` to close the SSH session and return to your local shell.
 Successful SSH connection using Termius, showing Ubuntu welcome screen and shell prompt
## [Core Syntax](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#core-syntax)
To connect to a remote system using SSH, weâll use the `ssh` command.
If you are using Windows, youâll need to install a version of OpenSSH in order to be able to `ssh` from a terminal. If you prefer to work in PowerShell, you can follow [Microsoftâs documentation](https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse) to add OpenSSH to PowerShell. If you would rather have a full Linux environment available, you can [set up WSL](https://www.digitalocean.com/community/tutorials/how-to-install-the-windows-subsystem-for-linux-2-on-microsoft-windows-10), the Windows Subsystem for Linux, which will include `ssh` by default. Finally, as a lightweight third option, you can install [Git for Windows](https://gitforwindows.org/), which provides a native Windows bash terminal environment that includes the `ssh` command. Each of these are well-supported and whichever you decide to use will come down to preference.
If you are using a Mac or Linux, you will already have the `ssh` command available in your terminal.
The most straightforward form of the command is:
```
ssh remote_host
```
Copy
The `remote_host` in this example is the IP address or domain name that you are trying to connect to.
This command assumes that your username on the remote system is the same as your username on your local system.
If your username is different on the remote system, you can specify it by using this syntax:
```
ssh remote_username@remote_host
```
Copy
Once you have connected to the server, you may be asked to verify your identity by providing a password. Later, we will cover how to generate keys to use instead of passwords.
To exit the ssh session and return back into your local shell session, type:
```
exit
```
Copy
## [How Does SSH Work?](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-does-ssh-work)
SSH works by connecting a client program to an **ssh server**, called `sshd`.
In the previous section, `ssh` was the client program. The *ssh server* was already running on the `remote_host` that we specified.
On nearly all Linux environments, the `sshd` server should start automatically. If it is not running for any reason, you may need to temporarily access your server through a web-based console or local serial console.
The process needed to start an ssh server depends on the distribution of Linux that you are using.
On Ubuntu, you can start the ssh server by typing:
```
sudo systemctl start ssh
```
Copy
That should start the sshd server, and you can then log in remotely.
As a bonus, if youâre using DigitalOcean, you donât necessarily need an SSH client at all. DigitalOcean provides a built-in **Console** feature for each Droplet. This browser-based terminal lets you access your server even if your SSH client is misconfigured or unavailable. Itâs especially helpful for first-time users or emergency access, keeping you fully within the DigitalOcean ecosystem without relying on third-party tools.
 Access your server through DigitalOceanâs browser-based Console, ideal for emergency access without an SSH client.
For a more detailed explanation of how SSH servers and clients interact, check out [SSH Essentials: Working with SSH Servers, Clients, and Keys](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys).
## [How To Configure SSH](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-configure-ssh)
When you change the configuration of SSH, you are changing the settings of the `sshd` server.
In Ubuntu, the main `sshd` configuration file is located at `/etc/ssh/sshd_config`.
Back up the current version of this file before editing:
```
sudo cp /etc/ssh/sshd_config{,.bak}
```
Copy
Open it using `nano` or your favorite text editor:
```
sudo nano /etc/ssh/sshd_config
```
Copy
You will want to leave most of the options in this file alone. However, there are a few you may want to take a look at:
/etc/ssh/sshd\_config
```
Port 22
```
Copy
The port declaration specifies which port the `sshd` server will listen on for connections. By default, this is `22`. You should probably leave this setting alone unless you have specific reasons to do otherwise. If you *do* change your port, we will show you how to connect to the new port later on.
/etc/ssh/sshd\_config
```
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
```
Copy
The host key declarations specify where to look for global host keys. We will discuss what a host key is later.
/etc/ssh/sshd\_config
```
SyslogFacility AUTH
LogLevel INFO
```
Copy
These two items indicate the level of logging that should occur.
If you are having difficulties with SSH, increasing the amount of logging may be a good way to discover what the issue is.
/etc/ssh/sshd\_config
```
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
```
Copy
These parameters specify some of the login information.
`LoginGraceTime` specifies how many seconds to keep the connection alive without successfully logging in.
It may be a good idea to set this time just a little bit higher than the amount of time it takes you to log in normally.
`PermitRootLogin` selects whether the **root** user is allowed to log in.
In most cases, this should be changed to `no` when you have created a user account that has access to elevated privileges (through `su` or `sudo`) and can log in through SSH in order to minimize the risk of anyone gaining root access to your server.
`strictModes` is a safety guard that will refuse a login attempt if the authentication files are readable by everyone.
This prevents login attempts when the configuration files are not secure.
/etc/ssh/sshd\_config
```
X11Forwarding yes
X11DisplayOffset 10
```
Copy
These parameters configure an ability called *X11 Forwarding*. This allows you to view a remote systemâs graphical user interface (GUI) on the local system.
This option must be enabled on the server and given to the SSH client during connection with the `-X` option.
After making your changes, save and close the file. If you are using `nano`, press `Ctrl+X`, then when prompted, `Y` and then Enter.
If you changed any settings in `/etc/ssh/sshd_config`, make sure you reload your `sshd` server to implement your modifications:
```
sudo systemctl reload ssh
```
Copy
You should thoroughly test your changes to ensure that they operate in the way you expect.
It may be a good idea to have a few terminal sessions open while you are making changes. This will allow you to revert the configuration if necessary without locking yourself out.
## [How To Use `~/.ssh/config` for Multiple SSH Connections](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-use-ssh-config-for-multiple-ssh-connections)
To simplify access to multiple servers, create or edit `~/.ssh/config`:
```
Host dev-server
HostName 192.168.1.10
User devuser
Port 2222
IdentityFile ~/.ssh/dev_key
```
Copy
Then connect using:
```
ssh dev-server
```
Copy
This is useful if you manage multiple SSH keys and nonstandard ports.
## [How To Log Into SSH with Keys](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-log-into-ssh-with-keys)
While it is helpful to be able to log in to a remote system using passwords, it is faster and more secure to set up *key-based authentication*.
### [How Does Key-based Authentication Work?](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-does-key-based-authentication-work)
Key-based authentication works by creating a pair of keys: a *private key* and a *public key*.
The *private key* is located on the clientâs machine and is secured and kept secret.
The *public key* can be given to anyone or placed on any server you wish to access.
When you attempt to connect using a key pair, the server will use the public key to create a message for the client computer that can only be read with the private key.
The client computer then sends the appropriate response back to the server, which will tell the server that the client is legitimate.
This process is performed automatically after you configure your keys.
To dive deeper into the mechanics behind SSH encryption and how the connection process works, read [Understanding the SSH Encryption and Connection Process](https://www.digitalocean.com/community/tutorials/understanding-the-ssh-encryption-and-connection-process).
### [How To Create SSH Keys](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-create-ssh-keys)
SSH keys should be generated on the computer you wish to log in *from*. This is usually your local machine.
Enter the following into the command line:
```
ssh-keygen -t rsa
```
Copy
You may be prompted to set a password on the key files themselves, but this is a fairly uncommon practice, and you should press enter through the prompts to accept the defaults. Your keys will be created at *~/.ssh/id\_rsa.pub* and *~/.ssh/id\_rsa*.
For a comprehensive walkthrough on configuring SSH key-based access, see [How to Configure SSH Key-Based Authentication on a Linux Server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server).
Change into the `.ssh` directory by typing:
```
cd ~/.ssh
```
Copy
Look at the permissions of the files:
```
ls -l
```
Copy
```
Output-rw-r--r-- 1 demo demo 807 Sep 9 22:15 authorized_keys
-rw------- 1 demo demo 1679 Sep 9 23:13 id_rsa
-rw-r--r-- 1 demo demo 396 Sep 9 23:13 id_rsa.pub
```
Copy
As you can see, the `id_rsa` file is readable and writable only to the owner. This helps to keep it secret.
The `id_rsa.pub` file, however, can be shared and has permissions appropriate for this activity.
### [How To Transfer Your Public Key to the Server](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-transfer-your-public-key-to-the-server)
If you currently have password-based access to a server, you can copy your public key to it by issuing this command:
```
ssh-copy-id remote_host
```
Copy
This will start an SSH session. After you enter your password, it will copy your public key to the serverâs authorized keys file, which will allow you to log in without the password next time.
## [Client-Side Options](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#client-side-options)
There are a number of optional flags that you can provide when connecting through SSH.
Some of these may be necessary to match the settings in the remote hostâs `sshd` configuration.
For instance, if you changed the port number in your `sshd` configuration, you will need to match that port on the client side by typing:
```
ssh -p port_number remote_host
```
Copy
**Note:** Changing your ssh port is a reasonable way of providing *security through obscurity*. If you are allowing SSH connections to a widely known server deployment on port `22` as normal and you have password authentication enabled, you will likely be attacked by many automated login attempts. Exclusively using key-based authentication and running SSH on a nonstandard port is not the most complex security solution you can employ, but you should reduce these to a minimum.
If you only want to execute a single command on a remote system, you can specify it after the host like so:
```
ssh remote_host command_to_run
```
Copy
You will connect to the remote machine, authenticate, and the command will be executed.
As we said before, if X11 forwarding is enabled on both computers, you can access that functionality by typing:
```
ssh -X remote_host
```
Copy
Providing you have the appropriate tools on your computer, GUI programs that you use on the remote system will now open their window on your local system.
## [Common SSH Errors and Troubleshooting Tips](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#common-ssh-errors-and-troubleshooting-tips)
| Error | Possible Cause | Recommended Solution |
|---|---|---|
| SSH Connection Refused | SSH service (`sshd`) not running or port blocked | Start SSH: `sudo systemctl start ssh`; check firewall rules |
| Permission Denied (Publickey) | Incorrect file permissions or missing public key | Fix permissions: `chmod 700 ~/.ssh`, `chmod 600 ~/.ssh/authorized_keys` |
| SSH Timeout or Hang | DNS issue, unreachable host, or blocked port | Use verbose debug: `ssh -vvv user@host`; check network/firewall |
## [Advanced SSH Errors and Troubleshooting Tips](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#advanced-ssh-errors-and-troubleshooting-tips)
| Error | Possible Cause | Advanced Solution |
|---|---|---|
| Host key verification failed | Mismatch in `known_hosts` file due to IP/host change | Remove old key: `ssh-keygen -R server_ip`; or edit `~/.ssh/known_hosts` manually |
| Too many authentication failures | Too many keys attempted by SSH agent | Force identity: `ssh -o IdentitiesOnly=yes -i ~/.ssh/id_rsa user@host` |
| Connection closed by remote host | Idle timeout or restricted config on remote server | Check `sshd_config` for `ClientAliveInterval`, `MaxAuthTries`, or login limits |
| Bad owner or permissions on .ssh | Loose file permissions pose a security risk | Ensure: `chmod 700 ~/.ssh`, `chmod 600 ~/.ssh/id_rsa`, `chmod 644 ~/.ssh/id_rsa.pub` |
| Cannot resolve hostname | Typo in hostname or DNS failure | Verify DNS, correct typos, or edit `/etc/hosts` for static resolution |
| Authentication refused: no methods available | Both password and key-based auth disabled on server | Ensure keys are installed or enable one method in `/etc/ssh/sshd_config` |
## [Disabling Password Authentication](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#disabling-password-authentication)
If you have created SSH keys, you can enhance your serverâs security by disabling password-only authentication. Apart from the console, the only way to log into your server will be through the private key that pairs with the public key you have installed on the server.
**Warning:** Before you proceed with this step, be sure you have installed a public key to your server. Otherwise, you will be locked out\!
As **root** or user with sudo privileges, open the `sshd` configuration file:
```
sudo nano /etc/ssh/sshd_config
```
Copy
Locate the line that reads `Password Authentication`, and uncomment it by removing the leading `#`. You can then change its value to `no`:
/etc/ssh/sshd\_config
```
PasswordAuthentication no
```
Copy
Two more settings that should not need to be modified (provided you have not modified this file before) are `PubkeyAuthentication` and `ChallengeResponseAuthentication`. They are set by default and should read as follows:
/etc/ssh/sshd\_config
```
PubkeyAuthentication yes
ChallengeResponseAuthentication no
```
Copy
After making your changes, save and close the file.
You can now reload the SSH daemon:
```
sudo systemctl reload ssh
```
Copy
Password authentication should now be disabled, and your server should be accessible only through SSH key authentication.
## [SSH Security Best Practices Checklist](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#ssh-security-best-practices-checklist)
- Disable password authentication (`PasswordAuthentication no`)
- Change default port from 22 to something else
- Use SSH keys instead of passwords
- Set `PermitRootLogin no`
- Enable automatic security updates
- Restrict SSH access via firewall (e.g., UFW or firewalld)
## [How to SSH on Windows, Linux, and macOS](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-ssh-on-windows-linux-and-macos)
**Windows:**
Use PowerShell, Git Bash, or WSL to access SSH.
Example:
```
ssh user@server_ip
```
Copy
**macOS/Linux:**
Use the built-in terminal and the same command.
Generate keys using:
```
ssh-keygen
```
Copy
## [Frequently Asked Questions (FAQs)](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#frequently-asked-questions-faqs)
**Q: What is SSH used for?**
[SSH, or Secure Shell](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys), is primarily used to securely log into remote systems, typically Linux-based servers. It creates an encrypted channel over an unsecured network, allowing you to execute commands, transfer files, and manage infrastructure securely. SSH is critical for system administrators, developers, and DevOps teams to remotely access virtual machines (like DigitalOcean Droplets), automate tasks with scripts, and even forward ports or tunnel traffic through secure connections for added protection and control.
**Q: How do I generate SSH keys?**
SSH keys are generated using the `ssh-keygen` utility, which creates a secure public-private key pair. Run `ssh-keygen -t rsa -b 4096` to create strong RSA keys. The private key remains on your local machine, typically stored in `~/.ssh/id_rsa`, while the public key (`id_rsa.pub`) is placed on the remote server. When connecting, the server uses the public key to verify your identity without transmitting passwords. Key-based authentication enhances both security and automation for server access.
**Q: What does âPermission deniedâ mean in SSH?**
The âPermission deniedâ error in SSH usually indicates an authentication failure. This may be caused by incorrect usernames, expired or improperly set permissions on your `.ssh` directory or key files, or missing public keys on the remote server. SSH requires the `~/.ssh` directory to have `700` permissions and private keys like `id_rsa` to have `600`. It could also mean that the SSH server disallows password authentication or root login, depending on how `sshd_config` is set.
**Q: Is SSH safe to use?**
Yes, SSH is considered one of the most secure methods for accessing remote systems. It uses asymmetric encryption and modern cryptographic algorithms to ensure confidentiality and data integrity. Security can be improved by disabling password authentication, using key pairs, changing the default port, enabling two-factor authentication (2FA), and using tools like Fail2Ban to prevent brute-force attempts. Regularly updating the SSH server and auditing logs also helps mitigate vulnerabilities and unauthorized access.
**Q: Can I use SSH on Windows?**
Absolutely. Windows now supports SSH natively through PowerShell and OpenSSH, especially in Windows 10 and later. You can also use Git Bash, which includes an SSH client, or enable the Windows Subsystem for Linux (WSL) for a full Linux environment. Each method allows you to use the `ssh` command to connect to servers. Generating SSH keys and configuring SSH access works similarly to Linux/macOS, making Windows a viable platform for remote system management via SSH.
## [Conclusion](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#conclusion)
Learning your way around SSH will greatly benefit any of your future cloud computing endeavors. As you use the various options, you will discover more advanced functionality that can make your life easier. SSH has remained popular because it is secure, lightweight, and useful in diverse situations.
To deepen your SSH knowledge, you can refer to these additional resources:
- [SSH Essentials: Working with SSH Servers, Clients, and Keys](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys) for a comprehensive guide on SSH fundamentals
- [Understanding the SSH Encryption and Connection Process](https://www.digitalocean.com/community/tutorials/understanding-the-ssh-encryption-and-connection-process) to learn about SSHâs security mechanisms
- [How to Configure SSH Key-Based Authentication on a Linux Server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server) for enhanced security practices
- [Working with SFTP](https://www.digitalocean.com/community/tutorials/how-to-use-sftp-to-securely-transfer-files-with-a-remote-server) to perform command line file transfers.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
[Learn more about our products](https://www.digitalocean.com/products "Learn more about our products")
### About the author(s)

Justin Ellingwood
Author
[See author profile](https://www.digitalocean.com/community/users/jellingwood)
Former Senior Technical Writer at DigitalOcean, specializing in DevOps topics across multiple Linux distributions, including Ubuntu 18.04, 20.04, 22.04, as well as Debian 10 and 11.
[See author profile](https://www.digitalocean.com/community/users/jellingwood)

Anish Singh Walia
Editor
Sr Technical Content Strategist and Team Lead
[See author profile](https://www.digitalocean.com/community/users/asinghwalia)
I help Businesses scale with AI x SEO x (authentic) Content that revives traffic and keeps leads flowing \| 3,000,000+ Average monthly readers on Medium \| Sr Technical Writer(Team Lead) @ DigitalOcean \| Ex-Cloud Consultant @ AMEX \| Ex-Site Reliability Engineer(DevOps)@Nutanix
[See author profile](https://www.digitalocean.com/community/users/asinghwalia)

Vinayak Baranwal
Editor
Technical Writer II
[See author profile](https://www.digitalocean.com/community/users/vinayakbaranwal)
Building future-ready infrastructure with Linux, Cloud, and DevOps. Full Stack Developer & System Administrator. Technical Writer @ DigitalOcean \| GitHub Contributor \| Passionate about Docker, PostgreSQL, and Open Source \| Exploring NLP & AI-TensorFlow \| Nailed over 50+ deployments across production environments.
[See author profile](https://www.digitalocean.com/community/users/vinayakbaranwal)
Category:
[Tutorial](https://www.digitalocean.com/community/tutorials?subtype=tutorial)
Tags:
[Linux Basics](https://www.digitalocean.com/community/tags/linux-basics)
[Security](https://www.digitalocean.com/community/tags/security)
[Ubuntu](https://www.digitalocean.com/community/tags/ubuntu)
[Networking](https://www.digitalocean.com/community/tags/networking)
[System Tools](https://www.digitalocean.com/community/tags/system-tools)
#### Still looking for an answer?
[Ask a question](https://www.digitalocean.com/community/questions)[Search for more help](https://www.digitalocean.com/community)
Was this helpful?
Yes
No
Comments(10)
Follow-up questions(0)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link\!
[Sign in/up to comment](https://www.digitalocean.com/api/dynamic-content/v1/login?success_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fcommunity%2Ftutorials%2Fhow-to-use-ssh-to-connect-to-a-remote-server&error_redirect=https%3A%2F%2Fwww.digitalocean.com%2Fauth-error&type=register)

[martinvoorzanger](https://www.digitalocean.com/community/users/martinvoorzanger)
[December 21, 2013](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=7621)
Show less
The ssh-copy-id was not working on my Mac, so Iâd like to share how I got it working.
1. Install ssh-copy-id sudo curl <https://raw.github.com/beautifulcode/ssh-copy-id-for-OSX/master/ssh-copy-id.sh> -o /usr/local/bin/ssh-copy-id sudo chmod +x /usr/local/bin/ssh-copy-id
2. Copy the public key: ssh-copy-id -i ~/.ssh/id\_rsa.pub â-p \<port number\> \<username\>@\<ip addressâ
Reply
(1) replies

[martinvoorzanger](https://www.digitalocean.com/community/users/martinvoorzanger)
[December 21, 2013](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=7622)
Show less
1. Copy the public key: ssh-copy-id -i ~/.ssh/id\_rsa.pub â-p portnumber username[@ipaddress](https://www.digitalocean.com/community/users/ipaddress)â , where portnumber username and ipaddress needs to be filled in
Reply
(1) replies

[budiain](https://www.digitalocean.com/community/users/budiain)
[March 11, 2014](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=10801)
Show less
Thank you very much, Mr. Justin. I can install whmsonic from ubuntu from your article.
Reply

[forgotmyorange](https://www.digitalocean.com/community/users/forgotmyorange)
[May 18, 2014](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=13128)
Show less
I did exactly as instructed and it all seemed to work but it changed nothing in regards to having to type in a password. I still have to type one in. Did you miss stating the obvious, like that we still have to make config changes on the server or something?
Reply
(1) replies

[Andrew SB](https://www.digitalocean.com/community/users/asb)
[May 19, 2014](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=13154)
Show less
[@forgotmyorange](https://www.digitalocean.com/community/users/forgotmyorange): If you connect with \<code\>ssh -vv root[@your](https://www.digitalocean.com/community/users/your).ip.address\</code\> it will add debugging output so that you can see what is happening behind the scenes. If it is actually connecting with the key, you should see something like:
\<pre\> debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/asb/.ssh/id\_rsa debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-rsa blen 279 \</pre\>
Reply

[wittrj](https://www.digitalocean.com/community/users/wittrj)
[September 11, 2014](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=18139)
Show less
my login isnât working for the console⌠any tips?
Reply
(1) replies

[redraw](https://www.digitalocean.com/community/users/redraw)
[September 18, 2014](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=18762)
Show less
Hey thanks. Itâs the clearest tutorial I found! and your blog looks nice.
I guess you forgot to mention you can disable password authentication after setting up SSH keys, as not to be exposed to brute force attacks.
1. Is SSH server included in every Ubuntu desktop machine? how should we enable it? Maybe youâve written an article before, Iâll search for it.
2. Does Ubuntu desktop provides a GUI interface in order to use -X option?
Reply
(1) replies

[Pavitra](https://www.digitalocean.com/community/users/pavitra)
[December 8, 2014](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=23922)
Show less
Hey thanks. Itâs very helpful tutorial.
I have query regarding to see the server console for the running processes. So, can you please suggest me the command to see the running server console, so that i will be able to see the errors if occurs?
Reply
(1) replies

[DrBeauWebber](https://www.digitalocean.com/community/users/drbeauwebber)
[March 7, 2017](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=56902)
Show less
Hi, Thanks, extremely clear guidance. The local system is Cygwin on a WIndows 7 PC, The remote system is Ubuntu.
I still have a problem :
```
"we sent a publickey packet" - but there is no reply :
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/jbww/.ssh/id_rsa (0x80061bd0),
debug2: key: /home/jbww/.ssh/id_dsa (0x0),
debug2: key: /home/jbww/.ssh/id_ecdsa (0x0),
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/jbww/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/jbww/.ssh/id_dsa
debug1: Trying private key: /home/jbww/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
```
Does anyone have an idea as to what I can try ?
Reply
(1) replies

[Kumar Bishojit](https://www.digitalocean.com/community/users/bishojit)
[October 14, 2017](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server?comment=65062)
Show less
On cPanel based server you can connect it easily.
Follow this video: <https://www.youtube.com/watch?v=9Yx1gZKgb5Y>
Reply
(1) replies
Load more comments
[](https://creativecommons.org/licenses/by-nc-sa/4.0/)This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
## Deploy on DigitalOcean
Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.
[Sign up](https://cloud.digitalocean.com/registrations/new?refcode=f6fcd01aaffb)
## Popular Topics
1. [AI/ML](https://www.digitalocean.com/community/tags/ai-ml)
2. [Ubuntu](https://www.digitalocean.com/community/tags/ubuntu)
3. [Linux Basics](https://www.digitalocean.com/community/tags/linux-basics)
4. [JavaScript](https://www.digitalocean.com/community/tags/javascript)
5. [Python](https://www.digitalocean.com/community/tags/python)
6. [MySQL](https://www.digitalocean.com/community/tags/mysql)
7. [Docker](https://www.digitalocean.com/community/tags/docker)
8. [Kubernetes](https://www.digitalocean.com/community/tags/kubernetes)
9. [All tutorials](https://www.digitalocean.com/community/tutorials)
10. [Talk to an expert](https://www.digitalocean.com/company/contact/sales?referrer=tutorials)
### Connect on Discord
Join the conversation in our Discord to connect with fellow developers
[Visit Discord](https://discord.gg/digitalocean)
## Featured tutorials
1. [SOLID Design Principles Explained: Building Better Software Architecture](https://www.digitalocean.com/community/tutorials/s-o-l-i-d-the-first-five-principles-of-object-oriented-design)
2. [How To Remove Docker Images, Containers, and Volumes](https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes)
3. [How to Create a MySQL User and Grant Privileges (Step-by-Step)](https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql)
- [All tutorials](https://www.digitalocean.com/community/tutorials)
- [All topic tags](https://www.digitalocean.com/community/tags)
##### Join the Tech Talk
- [Quick Start: How to SSH into a Remote Server in 5 Steps](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#quick-start-how-to-ssh-into-a-remote-server-in-5-steps)
- [Core Syntax](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#core-syntax)
- [How Does SSH Work?](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-does-ssh-work)
- [How To Configure SSH](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-configure-ssh)
- [How To Use \`~/.ssh/config\` for Multiple SSH Connections](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-use-ssh-config-for-multiple-ssh-connections)
- [How To Log Into SSH with Keys](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-log-into-ssh-with-keys)
- [Client-Side Options](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#client-side-options)
- [Common SSH Errors and Troubleshooting Tips](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#common-ssh-errors-and-troubleshooting-tips)
- [Advanced SSH Errors and Troubleshooting Tips](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#advanced-ssh-errors-and-troubleshooting-tips)
- [Disabling Password Authentication](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#disabling-password-authentication)
- [SSH Security Best Practices Checklist](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#ssh-security-best-practices-checklist)
- [How to SSH on Windows, Linux, and macOS](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-ssh-on-windows-linux-and-macos)
- [Frequently Asked Questions (FAQs)](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#frequently-asked-questions-faqs)
- [Conclusion](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#conclusion)
- ## Deploy on DigitalOcean
Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.
[Sign up](https://cloud.digitalocean.com/registrations/new?refcode=f6fcd01aaffb)
## Popular Topics
1. [AI/ML](https://www.digitalocean.com/community/tags/ai-ml)
2. [Ubuntu](https://www.digitalocean.com/community/tags/ubuntu)
3. [Linux Basics](https://www.digitalocean.com/community/tags/linux-basics)
4. [JavaScript](https://www.digitalocean.com/community/tags/javascript)
5. [Python](https://www.digitalocean.com/community/tags/python)
6. [MySQL](https://www.digitalocean.com/community/tags/mysql)
7. [Docker](https://www.digitalocean.com/community/tags/docker)
8. [Kubernetes](https://www.digitalocean.com/community/tags/kubernetes)
9. [All tutorials](https://www.digitalocean.com/community/tutorials)
10. [Talk to an expert](https://www.digitalocean.com/company/contact/sales?referrer=tutorials)
### Connect on Discord
Join the conversation in our Discord to connect with fellow developers
[Visit Discord](https://discord.gg/digitalocean)
## Featured tutorials
1. [SOLID Design Principles Explained: Building Better Software Architecture](https://www.digitalocean.com/community/tutorials/s-o-l-i-d-the-first-five-principles-of-object-oriented-design)
2. [How To Remove Docker Images, Containers, and Volumes](https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes)
3. [How to Create a MySQL User and Grant Privileges (Step-by-Step)](https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql)
- [All tutorials](https://www.digitalocean.com/community/tutorials)
- [All topic tags](https://www.digitalocean.com/community/tags)

## Become a contributor for community
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
[Sign Up](https://www.digitalocean.com/community/pages/write-for-digitalocean)

## DigitalOcean Documentation
Full documentation for every DigitalOcean product.
[Learn more](https://docs.digitalocean.com/)

## Resources for startups and AI-native businesses
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
[Learn more](https://www.digitalocean.com/resources)
## Get our newsletter
Stay up to date by signing up for DigitalOceanâs Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our [Privacy Policy](https://www.digitalocean.com/legal/privacy-policy)
## The developer cloud
Scale up as you grow â whether you're running one virtual machine or ten thousand.
[View all products](https://www.digitalocean.com/products)

## Start building today
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
[Sign up](https://cloud.digitalocean.com/registrations/new)

## Company
- [About](https://www.digitalocean.com/about)
- [Leadership](https://www.digitalocean.com/leadership/executive-management)
- [Blog](https://www.digitalocean.com/blog)
- [Careers](https://www.digitalocean.com/careers)
- [Customers](https://www.digitalocean.com/customers)
- [Partners](https://www.digitalocean.com/partners)
- [Referral Program](https://www.digitalocean.com/referral-program)
- [Affiliate Program](https://www.digitalocean.com/affiliates)
- [Press](https://www.digitalocean.com/press)
- [Legal](https://www.digitalocean.com/legal)
- [Privacy Policy](https://www.digitalocean.com/legal/privacy-policy)
- [Security](https://www.digitalocean.com/security)
- [Investor Relations](https://investors.digitalocean.com/)
## Products
- [Gradient⢠AI GPU Droplets](https://www.digitalocean.com/products/gradient/gpu-droplets)
- [Gradient⢠AI Bare Metal GPUs](https://www.digitalocean.com/products/gradient/bare-metal-gpus)
- [Gradient⢠AI 1-Click Models](https://www.digitalocean.com/products/gradient/1-click-models)
- [Gradient⢠AI Platform](https://www.digitalocean.com/products/gradient/platform)
- [Droplets](https://www.digitalocean.com/products/droplets)
- [Kubernetes](https://www.digitalocean.com/products/kubernetes)
- [Functions](https://www.digitalocean.com/products/functions)
- [App Platform](https://www.digitalocean.com/products/app-platform)
- [Load Balancers](https://www.digitalocean.com/products/load-balancers)
- [Managed Databases](https://www.digitalocean.com/products/managed-databases)
- [Spaces](https://www.digitalocean.com/products/spaces)
- [Block Storage](https://www.digitalocean.com/products/block-storage)
- [Network File Storage](https://www.digitalocean.com/products/storage/network-file-storage)
- [API](https://docs.digitalocean.com/reference/api)
- [Uptime](https://www.digitalocean.com/products/uptime-monitoring)
- [Cloud Security Posture Management (CSPM)](https://www.digitalocean.com/products/cloud-security-posture-management)
- [Identity and Access Management (IAM)](https://www.digitalocean.com/products/identity-access-management)
- [Cloudways](https://www.digitalocean.com/products/cloudways)
- [View all Products](https://www.digitalocean.com/products)
## Resources
- [Community Tutorials](https://www.digitalocean.com/community/tutorials)
- [Community Q\&A](https://www.digitalocean.com/community/questions)
- [CSS-Tricks](https://css-tricks.com/)
- [Write for DOnations](https://www.digitalocean.com/community/pages/write-for-digitalocean)
- [Currents Research](https://www.digitalocean.com/currents)
- [DigitalOcean Startups](https://www.digitalocean.com/startups)
- [Wavemakers Program](https://www.digitalocean.com/wavemakers)
- [Compass Council](https://www.digitalocean.com/research)
- [Open Source](https://www.digitalocean.com/open-source)
- [Newsletter Signup](https://www.digitalocean.com/community#iaan)
- [Marketplace](https://www.digitalocean.com/products/marketplace)
- [Pricing](https://www.digitalocean.com/pricing)
- [Pricing Calculator](https://www.digitalocean.com/pricing/calculator)
- [Documentation](https://docs.digitalocean.com/)
- [Release Notes](https://docs.digitalocean.com/release-notes)
- [Code of Conduct](https://www.digitalocean.com/community/pages/code-of-conduct)
- [Shop Swag](http://store.digitalocean.com/)
## Solutions
- [AI GPU Hosting](https://www.digitalocean.com/solutions/ai-gpu-hosting)
- [H100 Cloud GPU](https://www.digitalocean.com/solutions/h100-cloud-gpu)
- [AI Training GPU](https://www.digitalocean.com/solutions/ai-training-gpu)
- [GPU Inference](https://www.digitalocean.com/solutions/gpu-inference)
- [VPS Hosting](https://www.digitalocean.com/solutions/vps-hosting)
- [Website Hosting](https://www.digitalocean.com/solutions/website-hosting)
- [VPN](https://www.digitalocean.com/solutions/vpn)
- [Docker Hosting](https://www.digitalocean.com/solutions/docker-hosting)
- [Node.js Hosting](https://www.digitalocean.com/solutions/nodejs-hosting)
- [Web Mobile Apps](https://www.digitalocean.com/solutions/web-mobile-apps)
- [WordPress Hosting](https://www.digitalocean.com/solutions/wordpress-hosting)
- [Virtual Machines](https://www.digitalocean.com/solutions/virtual-machines)
- [View all Solutions](https://www.digitalocean.com/solutions)
## Contact
- [Support](https://www.digitalocean.com/support)
- [Sales](https://www.digitalocean.com/company/contact/sales?referrer=footer)
- [Report Abuse](https://www.digitalocean.com/company/contact/abuse)
- [System Status](https://status.digitalocean.com/)
- [Share your ideas](https://ideas.digitalocean.com/)
## Company
- [About](https://www.digitalocean.com/about)
- [Leadership](https://www.digitalocean.com/leadership/executive-management)
- [Blog](https://www.digitalocean.com/blog)
- [Careers](https://www.digitalocean.com/careers)
- [Customers](https://www.digitalocean.com/customers)
- [Partners](https://www.digitalocean.com/partners)
- [Referral Program](https://www.digitalocean.com/referral-program)
- [Affiliate Program](https://www.digitalocean.com/affiliates)
- [Press](https://www.digitalocean.com/press)
- [Legal](https://www.digitalocean.com/legal)
- [Privacy Policy](https://www.digitalocean.com/legal/privacy-policy)
- [Security](https://www.digitalocean.com/security)
- [Investor Relations](https://investors.digitalocean.com/)
## Products
- [Gradient⢠AI GPU Droplets](https://www.digitalocean.com/products/gradient/gpu-droplets)
- [Gradient⢠AI Bare Metal GPUs](https://www.digitalocean.com/products/gradient/bare-metal-gpus)
- [Gradient⢠AI 1-Click Models](https://www.digitalocean.com/products/gradient/1-click-models)
- [Gradient⢠AI Platform](https://www.digitalocean.com/products/gradient/platform)
- [Droplets](https://www.digitalocean.com/products/droplets)
- [Kubernetes](https://www.digitalocean.com/products/kubernetes)
- [Functions](https://www.digitalocean.com/products/functions)
- [App Platform](https://www.digitalocean.com/products/app-platform)
- [Load Balancers](https://www.digitalocean.com/products/load-balancers)
- [Managed Databases](https://www.digitalocean.com/products/managed-databases)
- [Spaces](https://www.digitalocean.com/products/spaces)
- [Block Storage](https://www.digitalocean.com/products/block-storage)
- [Network File Storage](https://www.digitalocean.com/products/storage/network-file-storage)
- [API](https://docs.digitalocean.com/reference/api)
- [Uptime](https://www.digitalocean.com/products/uptime-monitoring)
- [Cloud Security Posture Management (CSPM)](https://www.digitalocean.com/products/cloud-security-posture-management)
- [Identity and Access Management (IAM)](https://www.digitalocean.com/products/identity-access-management)
- [Cloudways](https://www.digitalocean.com/products/cloudways)
- [View all Products](https://www.digitalocean.com/products)
## Resources
- [Community Tutorials](https://www.digitalocean.com/community/tutorials)
- [Community Q\&A](https://www.digitalocean.com/community/questions)
- [CSS-Tricks](https://css-tricks.com/)
- [Write for DOnations](https://www.digitalocean.com/community/pages/write-for-digitalocean)
- [Currents Research](https://www.digitalocean.com/currents)
- [DigitalOcean Startups](https://www.digitalocean.com/startups)
- [Wavemakers Program](https://www.digitalocean.com/wavemakers)
- [Compass Council](https://www.digitalocean.com/research)
- [Open Source](https://www.digitalocean.com/open-source)
- [Newsletter Signup](https://www.digitalocean.com/community#iaan)
- [Marketplace](https://www.digitalocean.com/products/marketplace)
- [Pricing](https://www.digitalocean.com/pricing)
- [Pricing Calculator](https://www.digitalocean.com/pricing/calculator)
- [Documentation](https://docs.digitalocean.com/)
- [Release Notes](https://docs.digitalocean.com/release-notes)
- [Code of Conduct](https://www.digitalocean.com/community/pages/code-of-conduct)
- [Shop Swag](http://store.digitalocean.com/)
## Solutions
- [AI GPU Hosting](https://www.digitalocean.com/solutions/ai-gpu-hosting)
- [H100 Cloud GPU](https://www.digitalocean.com/solutions/h100-cloud-gpu)
- [AI Training GPU](https://www.digitalocean.com/solutions/ai-training-gpu)
- [GPU Inference](https://www.digitalocean.com/solutions/gpu-inference)
- [VPS Hosting](https://www.digitalocean.com/solutions/vps-hosting)
- [Website Hosting](https://www.digitalocean.com/solutions/website-hosting)
- [VPN](https://www.digitalocean.com/solutions/vpn)
- [Docker Hosting](https://www.digitalocean.com/solutions/docker-hosting)
- [Node.js Hosting](https://www.digitalocean.com/solutions/nodejs-hosting)
- [Web Mobile Apps](https://www.digitalocean.com/solutions/web-mobile-apps)
- [WordPress Hosting](https://www.digitalocean.com/solutions/wordpress-hosting)
- [Virtual Machines](https://www.digitalocean.com/solutions/virtual-machines)
- [View all Solutions](https://www.digitalocean.com/solutions)
## Contact
- [Support](https://www.digitalocean.com/support)
- [Sales](https://www.digitalocean.com/company/contact/sales?referrer=footer)
- [Report Abuse](https://www.digitalocean.com/company/contact/abuse)
- [System Status](https://status.digitalocean.com/)
- [Share your ideas](https://ideas.digitalocean.com/)
Š 2026 DigitalOcean, LLC.[Sitemap](https://www.digitalocean.com/sitemap).[Cookie Preferences]()
This site uses cookies and related technologies, as described in our [privacy policy](https://www.digitalocean.com/legal/privacy-policy/), for purposes that may include site operation, analytics, enhanced user experience, or advertising. You may choose to consent to our use of these technologies, or manage your own preferences. Please visit our [cookie policy](https://www.digitalocean.com/legal/cookie-policy) for more information.
Agree & Proceed
Decline All
Manage Choices
Loading...
## Community
## Product Docs
## Marketplace
## DigitalOcean Blog
navigate
go
exit |
| Readable Markdown | ### [Introduction](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#introduction)
One essential tool to master as a system administrator is SSH.
[SSH, or *Secure Shell*](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys), is a protocol used to securely log onto remote systems. It is the most common way to access remote Linux servers.
In this guide, we will discuss how to use SSH to connect to a remote system.
Deploy your frontend applications from GitHub using [DigitalOcean App Platform](https://www.digitalocean.com/products/app-platform). Let DigitalOcean focus on scaling your app.
## [Quick Start: How to SSH into a Remote Server in 5 Steps](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#quick-start-how-to-ssh-into-a-remote-server-in-5-steps)
1. **Open your terminal.**
- On **Linux/macOS**: Launch the Terminal app.
- On **Windows**: Use PowerShell, Git Bash, or WSL.
2. **Run the SSH command:**
```
ssh username@your_server_ip
```
3. **Review and accept the host fingerprint** if prompted.
4. **Authenticate** using your password or an SSH key (if configured).
5. **Youâre connected\!**
Type `exit` to close the SSH session and return to your local shell.
 Successful SSH connection using Termius, showing Ubuntu welcome screen and shell prompt
## [Core Syntax](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#core-syntax)
To connect to a remote system using SSH, weâll use the `ssh` command.
If you are using Windows, youâll need to install a version of OpenSSH in order to be able to `ssh` from a terminal. If you prefer to work in PowerShell, you can follow [Microsoftâs documentation](https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse) to add OpenSSH to PowerShell. If you would rather have a full Linux environment available, you can [set up WSL](https://www.digitalocean.com/community/tutorials/how-to-install-the-windows-subsystem-for-linux-2-on-microsoft-windows-10), the Windows Subsystem for Linux, which will include `ssh` by default. Finally, as a lightweight third option, you can install [Git for Windows](https://gitforwindows.org/), which provides a native Windows bash terminal environment that includes the `ssh` command. Each of these are well-supported and whichever you decide to use will come down to preference.
If you are using a Mac or Linux, you will already have the `ssh` command available in your terminal.
The most straightforward form of the command is:
```
ssh remote_host
```
The `remote_host` in this example is the IP address or domain name that you are trying to connect to.
This command assumes that your username on the remote system is the same as your username on your local system.
If your username is different on the remote system, you can specify it by using this syntax:
```
ssh remote_username@remote_host
```
Once you have connected to the server, you may be asked to verify your identity by providing a password. Later, we will cover how to generate keys to use instead of passwords.
To exit the ssh session and return back into your local shell session, type:
```
exit
```
## [How Does SSH Work?](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-does-ssh-work)
SSH works by connecting a client program to an **ssh server**, called `sshd`.
In the previous section, `ssh` was the client program. The *ssh server* was already running on the `remote_host` that we specified.
On nearly all Linux environments, the `sshd` server should start automatically. If it is not running for any reason, you may need to temporarily access your server through a web-based console or local serial console.
The process needed to start an ssh server depends on the distribution of Linux that you are using.
On Ubuntu, you can start the ssh server by typing:
```
sudo systemctl start ssh
```
That should start the sshd server, and you can then log in remotely.
As a bonus, if youâre using DigitalOcean, you donât necessarily need an SSH client at all. DigitalOcean provides a built-in **Console** feature for each Droplet. This browser-based terminal lets you access your server even if your SSH client is misconfigured or unavailable. Itâs especially helpful for first-time users or emergency access, keeping you fully within the DigitalOcean ecosystem without relying on third-party tools.
 Access your server through DigitalOceanâs browser-based Console, ideal for emergency access without an SSH client.
For a more detailed explanation of how SSH servers and clients interact, check out [SSH Essentials: Working with SSH Servers, Clients, and Keys](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys).
## [How To Configure SSH](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-configure-ssh)
When you change the configuration of SSH, you are changing the settings of the `sshd` server.
In Ubuntu, the main `sshd` configuration file is located at `/etc/ssh/sshd_config`.
Back up the current version of this file before editing:
```
sudo cp /etc/ssh/sshd_config{,.bak}
```
Open it using `nano` or your favorite text editor:
```
sudo nano /etc/ssh/sshd_config
```
You will want to leave most of the options in this file alone. However, there are a few you may want to take a look at:
/etc/ssh/sshd\_config
```
Port 22
```
The port declaration specifies which port the `sshd` server will listen on for connections. By default, this is `22`. You should probably leave this setting alone unless you have specific reasons to do otherwise. If you *do* change your port, we will show you how to connect to the new port later on.
/etc/ssh/sshd\_config
```
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
```
The host key declarations specify where to look for global host keys. We will discuss what a host key is later.
/etc/ssh/sshd\_config
```
SyslogFacility AUTH
LogLevel INFO
```
These two items indicate the level of logging that should occur.
If you are having difficulties with SSH, increasing the amount of logging may be a good way to discover what the issue is.
/etc/ssh/sshd\_config
```
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
```
These parameters specify some of the login information.
`LoginGraceTime` specifies how many seconds to keep the connection alive without successfully logging in.
It may be a good idea to set this time just a little bit higher than the amount of time it takes you to log in normally.
`PermitRootLogin` selects whether the **root** user is allowed to log in.
In most cases, this should be changed to `no` when you have created a user account that has access to elevated privileges (through `su` or `sudo`) and can log in through SSH in order to minimize the risk of anyone gaining root access to your server.
`strictModes` is a safety guard that will refuse a login attempt if the authentication files are readable by everyone.
This prevents login attempts when the configuration files are not secure.
/etc/ssh/sshd\_config
```
X11Forwarding yes
X11DisplayOffset 10
```
These parameters configure an ability called *X11 Forwarding*. This allows you to view a remote systemâs graphical user interface (GUI) on the local system.
This option must be enabled on the server and given to the SSH client during connection with the `-X` option.
After making your changes, save and close the file. If you are using `nano`, press `Ctrl+X`, then when prompted, `Y` and then Enter.
If you changed any settings in `/etc/ssh/sshd_config`, make sure you reload your `sshd` server to implement your modifications:
```
sudo systemctl reload ssh
```
You should thoroughly test your changes to ensure that they operate in the way you expect.
It may be a good idea to have a few terminal sessions open while you are making changes. This will allow you to revert the configuration if necessary without locking yourself out.
## [How To Use `~/.ssh/config` for Multiple SSH Connections](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-use-ssh-config-for-multiple-ssh-connections)
To simplify access to multiple servers, create or edit `~/.ssh/config`:
```
Host dev-server
HostName 192.168.1.10
User devuser
Port 2222
IdentityFile ~/.ssh/dev_key
```
Then connect using:
```
ssh dev-server
```
This is useful if you manage multiple SSH keys and nonstandard ports.
## [How To Log Into SSH with Keys](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-log-into-ssh-with-keys)
While it is helpful to be able to log in to a remote system using passwords, it is faster and more secure to set up *key-based authentication*.
### [How Does Key-based Authentication Work?](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-does-key-based-authentication-work)
Key-based authentication works by creating a pair of keys: a *private key* and a *public key*.
The *private key* is located on the clientâs machine and is secured and kept secret.
The *public key* can be given to anyone or placed on any server you wish to access.
When you attempt to connect using a key pair, the server will use the public key to create a message for the client computer that can only be read with the private key.
The client computer then sends the appropriate response back to the server, which will tell the server that the client is legitimate.
This process is performed automatically after you configure your keys.
To dive deeper into the mechanics behind SSH encryption and how the connection process works, read [Understanding the SSH Encryption and Connection Process](https://www.digitalocean.com/community/tutorials/understanding-the-ssh-encryption-and-connection-process).
### [How To Create SSH Keys](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-create-ssh-keys)
SSH keys should be generated on the computer you wish to log in *from*. This is usually your local machine.
Enter the following into the command line:
```
ssh-keygen -t rsa
```
You may be prompted to set a password on the key files themselves, but this is a fairly uncommon practice, and you should press enter through the prompts to accept the defaults. Your keys will be created at *~/.ssh/id\_rsa.pub* and *~/.ssh/id\_rsa*.
For a comprehensive walkthrough on configuring SSH key-based access, see [How to Configure SSH Key-Based Authentication on a Linux Server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server).
Change into the `.ssh` directory by typing:
```
cd ~/.ssh
```
Look at the permissions of the files:
```
ls -l
```
```
Output-rw-r--r-- 1 demo demo 807 Sep 9 22:15 authorized_keys
-rw------- 1 demo demo 1679 Sep 9 23:13 id_rsa
-rw-r--r-- 1 demo demo 396 Sep 9 23:13 id_rsa.pub
```
As you can see, the `id_rsa` file is readable and writable only to the owner. This helps to keep it secret.
The `id_rsa.pub` file, however, can be shared and has permissions appropriate for this activity.
### [How To Transfer Your Public Key to the Server](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-transfer-your-public-key-to-the-server)
If you currently have password-based access to a server, you can copy your public key to it by issuing this command:
```
ssh-copy-id remote_host
```
This will start an SSH session. After you enter your password, it will copy your public key to the serverâs authorized keys file, which will allow you to log in without the password next time.
## [Client-Side Options](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#client-side-options)
There are a number of optional flags that you can provide when connecting through SSH.
Some of these may be necessary to match the settings in the remote hostâs `sshd` configuration.
For instance, if you changed the port number in your `sshd` configuration, you will need to match that port on the client side by typing:
```
ssh -p port_number remote_host
```
**Note:** Changing your ssh port is a reasonable way of providing *security through obscurity*. If you are allowing SSH connections to a widely known server deployment on port `22` as normal and you have password authentication enabled, you will likely be attacked by many automated login attempts. Exclusively using key-based authentication and running SSH on a nonstandard port is not the most complex security solution you can employ, but you should reduce these to a minimum.
If you only want to execute a single command on a remote system, you can specify it after the host like so:
```
ssh remote_host command_to_run
```
You will connect to the remote machine, authenticate, and the command will be executed.
As we said before, if X11 forwarding is enabled on both computers, you can access that functionality by typing:
```
ssh -X remote_host
```
Providing you have the appropriate tools on your computer, GUI programs that you use on the remote system will now open their window on your local system.
## [Common SSH Errors and Troubleshooting Tips](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#common-ssh-errors-and-troubleshooting-tips)
| Error | Possible Cause | Recommended Solution |
|---|---|---|
| SSH Connection Refused | SSH service (`sshd`) not running or port blocked | Start SSH: `sudo systemctl start ssh`; check firewall rules |
| Permission Denied (Publickey) | Incorrect file permissions or missing public key | Fix permissions: `chmod 700 ~/.ssh`, `chmod 600 ~/.ssh/authorized_keys` |
| SSH Timeout or Hang | DNS issue, unreachable host, or blocked port | Use verbose debug: `ssh -vvv user@host`; check network/firewall |
## [Advanced SSH Errors and Troubleshooting Tips](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#advanced-ssh-errors-and-troubleshooting-tips)
| Error | Possible Cause | Advanced Solution |
|---|---|---|
| Host key verification failed | Mismatch in `known_hosts` file due to IP/host change | Remove old key: `ssh-keygen -R server_ip`; or edit `~/.ssh/known_hosts` manually |
| Too many authentication failures | Too many keys attempted by SSH agent | Force identity: `ssh -o IdentitiesOnly=yes -i ~/.ssh/id_rsa user@host` |
| Connection closed by remote host | Idle timeout or restricted config on remote server | Check `sshd_config` for `ClientAliveInterval`, `MaxAuthTries`, or login limits |
| Bad owner or permissions on .ssh | Loose file permissions pose a security risk | Ensure: `chmod 700 ~/.ssh`, `chmod 600 ~/.ssh/id_rsa`, `chmod 644 ~/.ssh/id_rsa.pub` |
| Cannot resolve hostname | Typo in hostname or DNS failure | Verify DNS, correct typos, or edit `/etc/hosts` for static resolution |
| Authentication refused: no methods available | Both password and key-based auth disabled on server | Ensure keys are installed or enable one method in `/etc/ssh/sshd_config` |
## [Disabling Password Authentication](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#disabling-password-authentication)
If you have created SSH keys, you can enhance your serverâs security by disabling password-only authentication. Apart from the console, the only way to log into your server will be through the private key that pairs with the public key you have installed on the server.
**Warning:** Before you proceed with this step, be sure you have installed a public key to your server. Otherwise, you will be locked out\!
As **root** or user with sudo privileges, open the `sshd` configuration file:
```
sudo nano /etc/ssh/sshd_config
```
Locate the line that reads `Password Authentication`, and uncomment it by removing the leading `#`. You can then change its value to `no`:
/etc/ssh/sshd\_config
```
PasswordAuthentication no
```
Two more settings that should not need to be modified (provided you have not modified this file before) are `PubkeyAuthentication` and `ChallengeResponseAuthentication`. They are set by default and should read as follows:
/etc/ssh/sshd\_config
```
PubkeyAuthentication yes
ChallengeResponseAuthentication no
```
After making your changes, save and close the file.
You can now reload the SSH daemon:
```
sudo systemctl reload ssh
```
Password authentication should now be disabled, and your server should be accessible only through SSH key authentication.
## [SSH Security Best Practices Checklist](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#ssh-security-best-practices-checklist)
- Disable password authentication (`PasswordAuthentication no`)
- Change default port from 22 to something else
- Use SSH keys instead of passwords
- Set `PermitRootLogin no`
- Enable automatic security updates
- Restrict SSH access via firewall (e.g., UFW or firewalld)
## [How to SSH on Windows, Linux, and macOS](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#how-to-ssh-on-windows-linux-and-macos)
**Windows:**
Use PowerShell, Git Bash, or WSL to access SSH.
Example:
```
ssh user@server_ip
```
**macOS/Linux:**
Use the built-in terminal and the same command.
Generate keys using:
```
ssh-keygen
```
## [Frequently Asked Questions (FAQs)](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#frequently-asked-questions-faqs)
**Q: What is SSH used for?**
[SSH, or Secure Shell](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys), is primarily used to securely log into remote systems, typically Linux-based servers. It creates an encrypted channel over an unsecured network, allowing you to execute commands, transfer files, and manage infrastructure securely. SSH is critical for system administrators, developers, and DevOps teams to remotely access virtual machines (like DigitalOcean Droplets), automate tasks with scripts, and even forward ports or tunnel traffic through secure connections for added protection and control.
**Q: How do I generate SSH keys?**
SSH keys are generated using the `ssh-keygen` utility, which creates a secure public-private key pair. Run `ssh-keygen -t rsa -b 4096` to create strong RSA keys. The private key remains on your local machine, typically stored in `~/.ssh/id_rsa`, while the public key (`id_rsa.pub`) is placed on the remote server. When connecting, the server uses the public key to verify your identity without transmitting passwords. Key-based authentication enhances both security and automation for server access.
**Q: What does âPermission deniedâ mean in SSH?**
The âPermission deniedâ error in SSH usually indicates an authentication failure. This may be caused by incorrect usernames, expired or improperly set permissions on your `.ssh` directory or key files, or missing public keys on the remote server. SSH requires the `~/.ssh` directory to have `700` permissions and private keys like `id_rsa` to have `600`. It could also mean that the SSH server disallows password authentication or root login, depending on how `sshd_config` is set.
**Q: Is SSH safe to use?**
Yes, SSH is considered one of the most secure methods for accessing remote systems. It uses asymmetric encryption and modern cryptographic algorithms to ensure confidentiality and data integrity. Security can be improved by disabling password authentication, using key pairs, changing the default port, enabling two-factor authentication (2FA), and using tools like Fail2Ban to prevent brute-force attempts. Regularly updating the SSH server and auditing logs also helps mitigate vulnerabilities and unauthorized access.
**Q: Can I use SSH on Windows?**
Absolutely. Windows now supports SSH natively through PowerShell and OpenSSH, especially in Windows 10 and later. You can also use Git Bash, which includes an SSH client, or enable the Windows Subsystem for Linux (WSL) for a full Linux environment. Each method allows you to use the `ssh` command to connect to servers. Generating SSH keys and configuring SSH access works similarly to Linux/macOS, making Windows a viable platform for remote system management via SSH.
## [Conclusion](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server#conclusion)
Learning your way around SSH will greatly benefit any of your future cloud computing endeavors. As you use the various options, you will discover more advanced functionality that can make your life easier. SSH has remained popular because it is secure, lightweight, and useful in diverse situations.
To deepen your SSH knowledge, you can refer to these additional resources:
- [SSH Essentials: Working with SSH Servers, Clients, and Keys](https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys) for a comprehensive guide on SSH fundamentals
- [Understanding the SSH Encryption and Connection Process](https://www.digitalocean.com/community/tutorials/understanding-the-ssh-encryption-and-connection-process) to learn about SSHâs security mechanisms
- [How to Configure SSH Key-Based Authentication on a Linux Server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server) for enhanced security practices
- [Working with SFTP](https://www.digitalocean.com/community/tutorials/how-to-use-sftp-to-securely-transfer-files-with-a-remote-server) to perform command line file transfers.
[](https://creativecommons.org/licenses/by-nc-sa/4.0/)This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License. |
| Shard | 83 (laksa) |
| Root Hash | 13428457316079428483 |
| Unparsed URL | com,digitalocean!www,/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server s443 |