Ansible
Python
Kubernetes
Java
SSH
Terraform
PowerShell
Password-less SSH connection
Password-less SSH connection
Creating a password-less SSH connection between Linux servers or between a Linux server and a Windows server involves generating SSH key pairs and configuring SSH access. Here's how you can do it:
For Linux to Linux and Linux to Windows – we recommend ed25519 instead of rsa ( refer the documentation for more details ). If any reason it is not supported in your windows version, You may use rsa
Linux to Linux Servers:
1. Generate SSH Key Pair: Run the following command on the source server:
bash ssh-keygen -t ed25519
2. Follow the prompts to generate the SSH key pair.
3. Copy Public Key to the Destination Server: Use ssh-copy-id or manually copy the public key to the destination server:
bash ssh-copy-id username@destination_server_ip
You'll need to enter the password for the destination server's user account.
3. Test the Connection: Try connecting to the destination server without a password:
bash ssh username@destination_server_ip
Linux to Windows Server (using OpenSSH):
1. Generate SSH Key Pair: Run the following command on the Linux server:
bash ssh-keygen -t ed25519 ssh-keygen -t rsa ( not recommend unless you are using older versions of Windows)
2. Follow the prompts to generate the SSH key pair.
3. Install OpenSSH Server on Windows: If not already installed, install the OpenSSH server feature on the Windows server.
4. Copy Public Key to the Windows Server:
- Manually copy the public key generated on the Linux server ( ~/.ssh/id_ed25519.pub) or (~/.ssh/id_rsa.pub) to the Windows server:
- Create the .ssh directory in the Windows user's home directory (C:\Users\username\.ssh).
- Copy the contents of the public key (id_ed25519.pub) or (id_rsa.pub) to a file named authorized_keys inside the .ssh directory.
For some Windows versions, Follow this method
5. Copy the public key to the Windows Server:
bash scp ~/.ssh/id_ed25519.pub Administrator@192.168.1.100:'C:\ProgramData\ssh\administrators_authorized_keys'
6: Set Correct ACLs for Authorized Keys
On the Windows Server, set the correct ACLs for the authorized keys:
powershell icacls.exe "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
7. Restart the SSH service:
powershell Restart-Service sshd
5. Test the Connection: Try connecting to the Windows server from the Linux server without a password:
bash ssh username@windows_server_ip
Note:
- Ensure SSH server is running and accessible on the destination server.
- Adjust firewall rules to allow SSH connections.
- Properly secure SSH configurations to enhance security.
- For Windows servers, ensure OpenSSH server feature is enabled and properly configured.
Once configured, you'll be able to SSH between the servers without entering a password.