The SSH folder in Linux usually means ~/.ssh, a hidden directory in a user’s home folder that stores SSH keys, connection settings, and records of servers the user has contacted. It is separate from the system-wide SSH configuration directory, /etc/ssh, which contains settings and host keys used by the machine’s SSH services.
What the SSH folder is
The tilde in ~/.ssh stands for the current user’s home directory. For a user named Maya, for example, the path might be /home/maya/.ssh; for the root account it is commonly /root/.ssh. The leading dot makes the directory hidden in many file managers and excludes it from ordinary directory listings unless hidden files are shown.
Linux does not require every account to have this directory. SSH-related commands may create it when needed, or a user can create it manually. Its contents depend on how that person uses SSH: someone who only connects to remote servers may have client keys and a known_hosts file, while an account that accepts SSH logins may also have an authorized_keys file.
“The SSH folder” is therefore a convenient name for a standard per-user location, not one special folder shared by every Linux user. Each account has its own home directory and, if created, its own .ssh directory.
Why Linux keeps SSH files there
SSH, or Secure Shell, provides encrypted connections between computers. A common use is opening a remote command-line session, but SSH can also transfer files and support other network tools. The local SSH client needs a place to find a user’s identity keys and personal connection preferences. The remote SSH server needs a way to check which public keys are allowed to log in to an account. The per-user ~/.ssh directory provides conventional locations for these files.
Keeping this information in a user’s home directory lets different accounts use different keys and server preferences without changing the whole machine’s configuration. For example, a developer can use one key for a work server and another for a personal service. The server-side account can independently list the public keys it accepts.
The system-wide directory, /etc/ssh, has a different role. It commonly contains the SSH daemon’s configuration file and host keys identifying the machine when it acts as a server. Do not confuse those host keys with your personal client keys: host keys identify the server, while a user’s private key can identify that user to a server.
Common files inside ~/.ssh
There is no required set of files, and filenames can be customized. These are some of the names people most often encounter:
id_ed25519andid_ed25519.pub: a private/public key pair generated with the Ed25519 algorithm. The private key has no.pubsuffix; the public key does.id_rsaandid_rsa.pub: an RSA key pair. Older installations or services may use RSA, though current choices depend on the OpenSSH version and the service’s compatibility requirements.authorized_keys: public keys that the account is allowed to use for authentication when connecting to this machine’s SSH server. It is generally read on the server, in the destination account’s home directory.known_hosts: host keys recorded for servers the SSH client has contacted. This helps the client notice when a server’s presented identity changes unexpectedly.config: optional personal client settings, such as host aliases, usernames, ports, and identity-file paths.id_ed25519-cert.pubor other certificate files: optional SSH certificates used in environments that issue certificates instead of distributing individual authorized public keys.
Names such as id_ed25519 are defaults, not rules. A key can have a descriptive name such as work_git, with its public counterpart named work_git.pub. Never assume that every file in the directory is safe to share: public-key files are designed to be distributed, but private keys and some local configuration data should be protected.
Finding, creating, and inspecting the folder
Open a terminal and check the current account’s home directory with printf '%s\n' "$HOME". To see whether the SSH directory exists, use ls -la ~/.ssh. The -a option includes hidden files. If the command reports that the path does not exist, that is not necessarily an error; it may simply mean the account has not used SSH in a way that created the directory.
Create the directory with appropriately restrictive permissions when you need it:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
The -p option avoids an error if the directory already exists. To inspect file names and permissions afterward, run ls -la ~/.ssh. To check ownership as well as permissions, use stat ~/.ssh or inspect a particular file with stat ~/.ssh/config. These checks are useful when a key exists but SSH refuses to use it.
If you are working with another account, remember that ~ refers to the home directory of the account running the command, not automatically the account you intend to configure. Avoid running SSH setup commands with sudo unless you deliberately want files owned by root. A root-owned key in a regular user’s home directory can cause confusing access problems.
Creating a key and using it to connect
A common way to create a modern SSH key pair is ssh-keygen -t ed25519. The program asks where to save the key and whether to protect it with a passphrase. Pressing Enter accepts the suggested path, usually ~/.ssh/id_ed25519, if that file does not already exist. Check the suggested filename before accepting: replacing an existing key could break access to services that rely on it.
The private key stays on the client computer and should not be sent to a server or pasted into a website. The matching .pub file is the public key. To enable key-based login, add that public key to the destination account’s ~/.ssh/authorized_keys, using a trusted method. Where available, ssh-copy-id user@example.com can install a public key on a server after you authenticate to it. The exact command and access method may differ on managed systems.
Once configured, connect with ssh user@example.com. If the key has a non-default name or the server uses a nonstandard port, specify those details, for example ssh -i ~/.ssh/work_git -p 2222 user@example.com. A passphrase protects the private key if the file is copied or exposed; an SSH agent can hold the unlocked key temporarily so it need not be re-entered for every connection.
SSH config and convenient host aliases
A personal ~/.ssh/config file can make repeated connections easier. For example, it might contain:
Host staging
HostName staging.example.com
User maya
Port 2222
IdentityFile ~/.ssh/work_git
After saving that entry, ssh staging uses the listed host name, account, port, and key. The alias is local to the client; it does not rename the remote machine or change its account. Configuration can also hold separate settings for different hosts, which helps prevent accidentally using the wrong username or identity.
Protect the config file from unnecessary access, especially if it contains internal server names or other sensitive operational details. A typical permission is chmod 600 ~/.ssh/config. Configuration syntax is sensitive to spelling and placement, so consult man ssh_config if an option appears to be ignored. Command-line options can override some configuration values, which is useful for one-off tests.
Permissions and private-key safety
SSH checks file permissions because a private key that other local users can read is not a trustworthy proof of identity. A common secure setup is mode 700 for the user’s .ssh directory and mode 600 for private keys and configuration files. A public key can normally be readable, but the directory and relevant files should belong to the account that uses them. On the server, authorized_keys is commonly set to 600.
These values are practical defaults, not a substitute for the server’s actual policy. OpenSSH’s strict permission checks can reject keys or ignore authorization files if ownership or write permissions are too broad. If you see a message such as “UNPROTECTED PRIVATE KEY FILE,” inspect the key’s ownership and mode instead of making it more permissive. For example, chmod 600 ~/.ssh/id_ed25519 tightens the private key’s permissions.
- Do not upload a private key to a source-code repository, send it in email, or copy it to a server just to enable login.
- Use a passphrase for valuable keys, and consider an agent for convenient use during a session.
- If a private key may have been exposed, stop using it, generate a replacement, and remove the old public key from systems that trusted it.
- When connecting to a new server, verify its identity through a trusted channel if the connection’s security matters. Do not blindly accept a changed host key.
Common problems and what to check
If SSH says Permission denied (publickey), the client and server may not be using a matching key, the public key may not be installed for the account you are logging in as, or the server may disallow that authentication method. Confirm the username and host, check that the intended public key is in the correct account’s authorized_keys, and review ownership and permissions on the server. Use ssh -v user@example.com for diagnostic output; it shows which identities the client attempts, but it does not reveal the private key itself.
If SSH says it cannot open an identity file, check the path and spelling. A key stored under a custom name will not necessarily be tried automatically. Pass it with -i or add an IdentityFile line to the host’s config entry. If the key is encrypted, enter its passphrase when requested or load it into an agent.
A warning that a remote host identification has changed deserves caution. The server may have been rebuilt and received new host keys, but a change can also signal that you are reaching a different machine than expected. Verify the change with the server administrator before removing the old entry from known_hosts. The warning is a security check, not merely a nuisance to suppress.
On a server, also check that the SSH service is running, that the intended port is reachable through the firewall, and that the server configuration permits the login method. Linux distributions vary in service names and configuration practices, so use the documentation for that system. Client-side keys alone cannot make a server accept connections if its service is unavailable or configured to reject them.
Frequently Asked Questions
Where is the SSH folder in Linux?
For a user, it is usually ~/.ssh inside that user’s home directory. The full path is often /home/username/.ssh, but home directories can be located elsewhere. The system-wide SSH configuration is usually under /etc/ssh.
Why can’t I see the .ssh folder?
Its name starts with a dot, so many file managers hide it by default. Show hidden files in the file manager, or use ls -la ~ in a terminal. It may also not exist yet if the account has not created or used SSH files.
Can I delete the .ssh folder?
You can, but deleting it may remove keys, host records, and custom connection settings. That can prevent key-based logins or cause SSH to ask about server identities again. Back up anything you need and check what the files are used for before deleting them.
Is it safe to share an SSH key?
Share only the public key, the file ending in .pub, when a trusted service or administrator asks for it. Keep the matching private key secret. Anyone who obtains an unprotected private key may be able to authenticate wherever its public key is authorized.
What is the difference between authorized_keys and known_hosts?authorized_keys is used on the server to list public keys allowed to log in to an account. known_hosts is used by the client to remember server identities it has encountered. One helps a server recognize users; the other helps a client recognize servers.
Key takeaway
When someone asks for the SSH folder in Linux, they usually mean the current user’s hidden ~/.ssh directory. It holds personal SSH client data and, for accounts receiving SSH logins, may contain authorized public keys. Keep private keys private, use sensible ownership and permissions, and treat /etc/ssh as the separate system-wide location for SSH service configuration and host identity files.