How to make a Password-Less Login from Windows to Linux using OpenSSH?

5.8k views Asked by At

I installed the OpenSSH on my Windows 7 Machine. I want to connect to the remote Linux machine without typing password. I followed the bellow instructions but the SSH needs password to establish the connection yet.

  1. Open CMD and run: ssh-keygen -t rsa (The public and private keys are generated in the C:\Users\user.ssh) folder
  2. Copy the id_rsa.pub content into /home/kouhi/.ssh/authorized_keys in my Linux remote machine
  3. In Linux Machine run: chmod 700 .ssh
  4. In Linux Machine run: chmod 644 .ssh/authorized_keys

When I try to Ssh [email protected] the connection ask me the password yet. Also I tied Ssh -i C:\Users\user.ssh\id_rsa [email protected]

Also I get the following reply when run the ssh command:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'C:\\Users\\user\\id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: C:\\Users\\user\\id_rsa
2

There are 2 answers

1
DomQ On

As per this other question:

Right-click on the [private key file], select Properties then Security. Click Advanced, then Edit. Uncheck "Inheritable" and choose "Remove" in the dialog. Remove any explicit permissions left, add a "Full Access" permission to your username.

0
user20621573 On

Step 1 : Open your windows powershell

Step 2 : Type command ssh-keygen -t rsa

Step 3 : Now a private and public is generated and we have to copy this public key into the remote linux server.For that do the below steps. - Copy the public key stored C:\Users\User/.ssh/id_rsa.pub (Don't copy through GUI as it will give error,use powershell itself)

Step 4 : Now login to your remote server using your ID and password

Step 5 : Now paste the copied public key in /.ssh/authorized_keys using vim editor.

Step 6 : Now login from your windows powershell without password

TIPS : Try ssh restart , clear your earlier generated keys in authorised key folder and id_rsa.pub if you get errors and do as fresh