LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-17-2017, 11:36 AM   #1
elbek
LQ Newbie
 
Registered: Feb 2017
Location: Uzbekistan
Distribution: Mint, Fedora
Posts: 7

Rep: Reputation: Disabled
ssh passwordless login from windows to linux fails


I am sure this has been asked many times, for some reason I have still problem with getting it to work.

I have a generated public and private key on my windows machine and copied the public key:

Code:
    ssh-copy-id -i ~/.ssh/id_rsa.pub ekamolid@host
then on the server I did:

Code:
    chmod 700 .ssh
    chmod 644 authorized_keys
on local machine I run:

Code:
    chmod 700 id_rsa
`sshd_config` file has:

Code:
 - `RSAAuthentication yes`
 - `PubkeyAuthentication yes`
I restarted ssh server on remote server.

when try:

Code:
ssh ekamolid@host
I get following error in `/var/log/secure`:

Code:
> Feb 17 06:36:56 bur00cpw sudo: pam_unix(sudo:auth): authentication failure; logname=ekamolid uid=0 euid=0 tty=pts/3 ruser= rhost=  user=ekamolid
running ssh in debug mode is giving
Failed publickey for user from ...

What am I missing here?
 
Old 02-17-2017, 12:26 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137
How are you sshing from the Windows machine? Cygwin or ...?

Code:
chmod 644 authorized_keys
needs to be
Code:
chmod 600 ~/.ssh/authorized_keys
Your home directory also needs to be locked down
Code:
chmod 750 ~
(more restrictive than 750 is fine, but less restrictive is not)
 
Old 02-17-2017, 12:48 PM   #3
elbek
LQ Newbie
 
Registered: Feb 2017
Location: Uzbekistan
Distribution: Mint, Fedora
Posts: 7

Original Poster
Rep: Reputation: Disabled
I using git bash, I have open ssh installed on windows side, so I tried with windows command line ssh command with the same result. I have corrected the permission as you outlined without any luck. What are the other trouble shooting steps to dig more into?

Thanks for your help!
 
Old 02-17-2017, 12:55 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137Reputation: 2137
I know absolutely nothing about openssh on the Windows command line. Does it even have a ~/.ssh directory with keys inside? "~/" is not a valid location on the Windows filesystem. How did you generate the keys?

On the Linux system, try generating a key and adding it to the authorized_keys file, then see if you can ssh to yourself without a password
Code:
ssh-keygen -t rsa  # keep hitting enter through the prompts to take the default values
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh localhost
If that works, you know the server is configured correctly, then you can focus on the Windows side.
 
Old 02-17-2017, 01:00 PM   #5
elbek
LQ Newbie
 
Registered: Feb 2017
Location: Uzbekistan
Distribution: Mint, Fedora
Posts: 7

Original Poster
Rep: Reputation: Disabled
I did exactly the same way to generate keys, using git bash.
Code:
ssh-keygen -t rsa
then copy the public key to remote linux machine.

I tried to login to localhost public/private keys and it worked fine.

Looks like issue is on the windows side.
 
Old 02-17-2017, 01:26 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
Windows does have a perfectly-serviceable SSH client that is called putty. I have successfully used it to connect back-and-forth between Linux and Windows for many years. "It's just ... Win-doze ... that's all."

There are (of course) various differences. I found this site which seems to cover the subject well: https://devops.profitbricks.com/tuto...ty-on-windows/

Quote:
SSH can handle authentication using a traditional username and password combination or by using a public and private key pair. The SSH key pair establishes trust between the client and server, thereby removing the need for a password during authentication. While not required, the SSH private key can be encrypted with a passphrase for added security.

The PuTTY SSH client for Microsoft Windows does not share the same key format as the OpenSSH client. Therefore, it is necessary to create a new SSH public and private key using the PuTTYgen tool or convert an existing OpenSSH private key.

Last edited by sundialsvcs; 02-17-2017 at 01:31 PM.
 
Old 02-17-2017, 01:29 PM   #7
elbek
LQ Newbie
 
Registered: Feb 2017
Location: Uzbekistan
Distribution: Mint, Fedora
Posts: 7

Original Poster
Rep: Reputation: Disabled
The purpose is we are given windows machine which should do build automatically and deploy artifact to list of linux machines, I was given user name and public private keys for the user. the passwordless login happens during deployment which uses plain ssh command to do this, for this I should get plain ssh command working from windows console. Maybe there are other options I am missing, but this is the approach I am taking now.

Thanks.
 
Old 02-19-2017, 11:59 AM   #8
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
Still not seen a confirmation on what you are using to connect from Windows to Linux. If this is putty, then you need to convert the private keys to .ppk format to be able to use them with the putty client.
 
Old 03-10-2017, 09:29 AM   #9
elbek
LQ Newbie
 
Registered: Feb 2017
Location: Uzbekistan
Distribution: Mint, Fedora
Posts: 7

Original Poster
Rep: Reputation: Disabled
Sorry for late response back, It had to do with windows itself, I installed cygwin and passed the right key with -i and worked fine.

BTW, at home I installed fedora for personal use, so I expect to be active here more often.
Thanks for all your help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH Login - Bypass public Key check (temp disable passwordless login) Lunar Linux - Networking 1 02-23-2014 05:25 AM
Passwordless ssh works. Normal login/ssh Fails. gurunarayanan Linux - Newbie 9 11-08-2012 05:42 AM
SSH passwordless login fails at send_pubkey_test HGScherneck Linux - Software 7 01-20-2012 11:01 AM
Passwordless SSH login triley Linux - General 3 11-14-2008 04:07 PM
passwordless login on the same machine via ssh athreyavc Linux - Server 2 06-20-2008 01:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration