Skip to main content

Unlocking SSH: How to Access Servers Without a Password

In this article, we will demonstrate how to configure passwordless SSH authentication using public–private key pairs, providing a more secure and efficient method for accessing remote systems without the need for manual password entry.

Why you should witch to SSH key authentication

When you frequently connect to remote machines over SSH, switching from password-based logins to key-based authentication can make your workflow smoother and more secure. Rather than typing a password every time, your connection is verified automatically through a pair of cryptographic keys — one private and one public.

Your private key stays safely on your local computer, while the public key is stored on the remote servers you connect to. You can protect the private key with a passphrase for an extra layer of security.

System Overview

In this configuration, we will create passwordless SSH connections between server-graz and server-wien in both directions. This means each server can connect to the other securely and without requiring a password, using SSH key-based authentication.

Server: server-graz 
Server: server-wien

As a quick verification, attempting to connect to server-wien currently prompts for a password, since passwordless authentication has not yet been configured.
[root@server-graz ~]# ssh server-wien
root@server-wien's password: 

Generate SSH keys

We’ll begin by generating an SSH key on server-graz without a passphrase, and then transfer the public key to server-wien to enable passwordless access.
[root@server-graz ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:Vp/109X0La3LEwuCpTIvX3ZX5fmPIH5JtcR6NhtjxrE root@server-graz
The key's randomart image is:
+---[RSA 3072]----+
|                .|
|               o+|
|          o  .o B|
|         = . o===|
|      o S . +=o*=|
|       =   .ooE=o|
|      . . +.o**=.|
|       o + ooo.o.|
|        . ..  . .|
+----[SHA256]-----+
Location of the keys

The SSH key files are saved by default in the ~/.ssh directory. If this directory doesn’t exist, it will be created automatically.
[root@server-graz ~]# ls -ltra /root/.ssh/
total 24
dr-xr-x---. 3 root root 4096 Oct 25 14:37 ..
-rw-------. 1 root root  925 Oct 25 14:56 known_hosts.old
-rw-------. 1 root root 1665 Oct 25 14:57 known_hosts
-rw-r--r--. 1 root root  570 Nov  2 12:44 id_rsa.pub → private public
-rw-------. 1 root root 2602 Nov  2 12:44 id_rsa → private key
drwx------. 2 root root 4096 Nov  2 12:44 .
Copy the keys and test passwordless login
[root@server-graz ~]# ssh-copy-id root@server-wien
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@server-wien's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@server-wien'"
and check to make sure that only the key(s) you wanted were added.

[root@server-graz ~]# ssh server-wien
Last login: Sun Nov  2 12:40:21 2025 from 192.168.56.1
[root@server-wien ~]# 
We now need to repeat the same procedure on server-wien to enable passwordless SSH access to server-graz.
[root@server-wien ~]# ssh key-gen
ssh: Could not resolve hostname key-gen: Name or service not known
[root@server-wien ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:m+Wq6/4GFCfWUInXUGtiFoWuSCsbE59Equ2fab/OpiA root@server-wien
The key's randomart image is:
+---[RSA 3072]----+
|      .=+Bo      |
|    . = *...     |
|   o . *+ o      |
|  o o .o.o       |
| o = = .S .      |
|. = = o  =       |
|E..=   .o .      |
| .o..+. ..       |
|   o=BX*o        |
+----[SHA256]-----+
[root@server-wien ~]# ssh-copy-id root@server-graz
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@server-graz's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@server-graz'"
and check to make sure that only the key(s) you wanted were added.

[root@server-wien ~]# ssh server-graz
Last login: Sun Nov  2 12:40:10 2025 from 192.168.56.1
[root@server-graz ~]# 

Should you use a passphrase for your SSH private key?

It’s important to note that only the public key is intended to be shared. The private key must always remain secure on your local system. If someone gains access to your private key, they can authenticate to any server where the corresponding public key is authorized.

If you ever suspect that your private key has been compromised, you should immediately revoke and replace the key pair. This involves removing the old public key from all authorized systems, generating a new key pair using ssh-keygen, and deploying the new public key to each remote host.

There are situations where using a key without a passphrase is acceptable or even required—for example, during the installation of Oracle Grid Infrastructure, where passwordless SSH configuration is mandatory for communication between cluster nodes.

However, a passphrase-protected private key adds an extra layer of security, as the passphrase must be entered each time the key is used. While this slightly reduces convenience, it protects the key from unauthorized use if it’s ever copied or stored on removable media. If you frequently work from multiple client systems or maintain backups of your keys, it’s highly recommended to secure your private key with a passphrase.

Comments

Popular posts from this blog

In-Place Upgrade from Oracle Linux 7 to 8 Using LEAPP

Upgrading from Oracle Linux 7 to Oracle Linux 8 is important to keep your system secure, stable, and supported. Oracle Linux 7 is now out of support, which means it no longer receives updates, security patches, or fixes. Moving to Oracle Linux 8 ensures you continue getting updates, new features, and better performance. The LEAPP tool makes this upgrade easier by allowing an in-place upgrade, so you don’t need to reinstall the system from scratch. It checks if your system is ready, identifies potential issues, and helps guide you through the upgrade process. This guide will walk you through the basic steps and requirements to successfully upgrade Oracle Linux 7 to Oracle Linux 8 using LEAPP. Oracle Lifetime Support Policy Regarding upgrading Oracle Linux 7 to Oracle Linux 8, here are a few key points to consider: Review the official documentation thoroughly before starting the upgrade process Ensure you have a complete backup in place, as this is an in-place upgrade and you may n...

Step-by-Step Guide to Renewing OLVM Certificates in Version 4.3

Managing certificates is a critical administrative task in Oracle Linux Virtualization Manager (OLVM) environments, as expired certificates can result in host disconnections, authentication failures, and service disruptions. In this article, we will cover the process of renewing certificates in OLVM version 4.3 before they expire, ensuring secure communication between the engine and managed KVM hosts. For this procedure, we will use the OlvmKvmCerts utility provided by Oracle to renew the required certificates. In OLVM 4.3, although some engine-related certificates can be renewed using the engine-setup command, not all certificates are automatically refreshed. Certain components require manual renewal because the certificate renewal process in this version is not fully automated. It is important to note that this limitation has been addressed in  OLVM 4.4.10.7-1.0.24 and later.  Additionally, OLVM 4.3 has been unsupported since October 2022, and OLVM 4.4 reached end of su...

Oracle 19c: Data Guard Physical Standby Setup Guide

In this blog post, we’ll walk through the process of creating a Data Guard Physical Standby database in Oracle Database 19c, where ASM (Automatic Storage Management) and OMF (Oracle Managed Files) are used for storage management.  Setting up a standby database with Data Guard enhances the high availability, disaster recovery, and data protection capabilities of your Oracle environment.  By leveraging ASM and OMF, we simplify file management and ensure optimal performance and flexibility. This guide provides a step-by-step approach, from preparing the primary database to configuring the standby environment, ensuring a smooth and reliable setup. Environment Overview In this setup, we have two database servers configured for a Data Guard Physical Standby environment: Primary Server : server-graz – This server hosts the primary database named graz . Standby Server : server-salzburg – This server will act as the physical standby. Both servers are configured to use ASM (Au...