SSH Connection Permission Denied on New Ubuntu 22.04 LTS Server

Abstract: Resolve SSH permission denied errors on Ubuntu 22.04 by fixing file permissions, verifying usernames, and configuring sshd settings.

Created: 2026-08-15 by

SSH Permission Denied on Ubuntu 22.04 typically stems from incorrect file permissions, disabled password authentication in sshd_config, or using the wrong username. Verify your user exists, check /etc/ssh/sshd_config settings, and ensure private keys have strict permissions like 600 to resolve the immediate connection failure.

Verifying Username and Authentication Method

The most common reason for a "Permission denied" error is attempting to log in with a non-existent user or an unsupported authentication method. By default, Ubuntu servers often disable password authentication for security reasons, requiring SSH key-based login instead. If you are trying to use a password, you must first confirm that the user account actually exists on the system. You can verify this by checking the /etc/passwd file or asking your hosting provider if they created a specific user like ubuntu or root. If you are connecting as root, note that many cloud providers disable direct root login via SSH for security hardening. In such cases, you should connect as the default user (often ubuntu for standard images) and then use sudo su - to gain root privileges after logging in. This two-step process avoids the permission denial while maintaining security standards. For those who genuinely need password authentication, you must modify the SSH daemon configuration. Open the configuration file at /etc/ssh/sshd_config and locate the line starting with PasswordAuthentication. Change it to yes and restart the SSH service using sudo systemctl restart sshd. However, relying on passwords is discouraged; generating an SSH key pair and adding the public key to ~/.ssh/authorized_keys is the recommended approach.

Checking File Permissions on the Server

SSH has strict requirements regarding file permissions to prevent unauthorized access to private keys and user directories. If the permissions on your home directory, the .ssh folder, or the authorized_keys file are too open, the SSH server will reject the connection for security reasons. Specifically, the authorized_keys file must not be writable by group or others. To fix this, log in via the console or recovery mode if SSH is blocked, and run the following commands:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chown -R $USER:$USER ~/.ssh
These commands set the directory to read, write, and execute only for the owner, the key file to read and write only for the owner, and ensure the ownership is correct. Incorrect permissions here are a frequent cause of silent failures where the server accepts the connection but immediately closes it with a permission error.

Validating Client-Side Key Permissions

Just as the server checks its own files, the client machine also enforces strict permissions on private keys. If your local private key file (usually located in ~/.ssh/id_rsa) has permissions that allow other users to read it, SSH will refuse to use it. On your MacBook, check the permissions of your key file using ls -l ~/.ssh/id_rsa. The output should show -rw------- (600). If the permissions are incorrect, update them with chmod 600 ~/.ssh/id_rsa. Additionally, ensure that the key you are using matches the public key uploaded to the server. Mismatched keys result in authentication failures. You can test the connection with verbose output by running ssh -v user@server_ip. Look for lines indicating "Offering public key" and whether the server responds with "Server accepts key".

Reviewing SSH Daemon Configuration

Sometimes the issue lies deeper within the SSH daemon configuration. Ensure that PubkeyAuthentication is set to yes in /etc/ssh/sshd_config. Also, verify that the AuthorizedKeysFile points to the correct location, which is typically .ssh/authorized_keys. If you have recently changed the hostname or IP address, ensure that any firewall rules or security groups associated with the instance allow inbound traffic on port 22. For more complex networking issues, refer to our guide on [Ubuntu Server 22.04 Unreachable via SSH After Time](/news/1441906/ubuntu-server-22-04-unreachable-via-ssh), which covers time synchronization problems that can affect certificate validation. Similarly, if you are using a static IP, check [Ubuntu Server Unreachable Via SSH: Static IP Configuration Issue](/news/1441842/ubuntu-server-ssh-unreachable-with-static-ip) for network layer troubleshooting.

What if I still cannot connect?

If the above steps do not resolve the issue, try connecting with the -o StrictHostKeyChecking=no flag to bypass host key verification errors, though this is less likely to cause permission denied errors. As a last resort, log in locally or via the cloud provider's web console to reset the user password or regenerate the SSH key pair. For general connectivity slowdowns, see [Debugging General Slowdowns and SSH Login Issues on Ubuntu Servers](/news/1401456/debug-slowdowns-ssh-issues-on-ubuntu-servers).

Frequently Asked Questions

Why does SSH say "Permission denied" even with the correct password?

Password authentication is often disabled by default on Ubuntu 22.04 servers for security. You must either enable it in sshd_config or switch to using SSH key-based authentication. Always verify that PasswordAuthentication yes is present and the service is restarted.

Can I log in as root directly?

Most cloud providers disable direct root login via SSH. You should log in as the default user (e.g., ubuntu) and then escalate privileges using sudo su -. Direct root access is considered a security risk and is frequently blocked by default configurations.

How do I check if my SSH key permissions are correct?

Run ls -l ~/.ssh/id_rsa on your local machine. The permissions should be 600 (-rw-------). If they are more permissive, SSH will ignore the key. Use chmod 600 ~/.ssh/id_rsa to fix this.

What if I lost access and cannot log in locally?

Use your cloud provider's rescue console or VNC access to log in directly. Once inside, you can reset permissions, edit sshd_config, or add your new public key to authorized_keys. See [Unable to SSH into Ubuntu Server: Log in Locally First](/news/1374156/ssh-into-ubuntu-server-log-in-locally) for detailed steps.

Does changing the IP address cause permission denied errors?

Changing the IP address does not directly cause permission denied errors, but it may trigger host key verification issues. Clear the old entry in ~/.ssh/known_hosts if you get a "host key verification failed" message. For static IP related issues, refer to our guide on static IP configuration.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More