Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SSH key authentication of a dynamic IP system [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
schmeggahead
Guru
Guru


Joined: 25 Feb 2003
Posts: 314
Location: Columbus, Ohio

PostPosted: Sat Sep 15, 2007 4:46 pm    Post subject: SSH key authentication of a dynamic IP system [SOLVED] Reply with quote

I'm looking at the SSH authentication available and wondering if I can do the following:

I would like to sign in from a remote system with a dynamic IP address and authenticate that machine with an RSA key - it doesn't have a host name to resolve to go in the SSH host file (to allow authentication).

Would it be better to just use a user RSA key and allow only one user through that port?

I would really like to restrict any access to the SSH from any system that doesn't present that key.

I would still like to have to enter user name and password in the login process so that anyone with the private key has to have the pass phrase, user name and that user's password.


Last edited by schmeggahead on Sun Sep 23, 2007 5:45 pm; edited 1 time in total
Back to top
View user's profile Send private message
sschlueter
Guru
Guru


Joined: 26 Jul 2002
Posts: 578
Location: Dortmund, Germany

PostPosted: Sun Sep 16, 2007 12:10 am    Post subject: Reply with quote

I don't quite understand the problem... an rsa key in ~/.ssh/authorized_keys may contain a "from" option to enable host name matching in addition to public key authentication, but this is optional, you don't have to use it.
Back to top
View user's profile Send private message
schmeggahead
Guru
Guru


Joined: 25 Feb 2003
Posts: 314
Location: Columbus, Ohio

PostPosted: Sun Sep 16, 2007 12:14 pm    Post subject: Reply with quote

Here's what I really want to do:

Setup SSH to accept only certificates as authentication and stop accepting any other form of authentication (including passwords).

I want to do this on a port other than 22.

Meanwhile, I would like the existing port 22 to allow password authentication.

This way I can open the other port through the firewall and be assured the private key must be used to gain access and all others would be refused.

Here's what I think I need to do:
  • clone the /etc/init.d/sshd script to sshdx
  • point sshdx to a different config file sshdx_config
  • change configuration to port xxxx
  • change contiguration to support certificate authentication (don't understand how to do this)
  • change configuration to disable password authentication (don't know how to do this either)"
  • test is
  • rc-update add sshdx default
Back to top
View user's profile Send private message
xbmodder
Guru
Guru


Joined: 25 Feb 2004
Posts: 404

PostPosted: Sun Sep 16, 2007 9:26 pm    Post subject: Reply with quote

* clone the /etc/init.d/sshd script to sshdx
* point sshdx to a different config file sshdx_config
* change configuration to port xxxx
* change contiguration to support certificate authentication (don't understand how to do this)
* change configuration to disable password authentication (don't know how to do this either)"
* test is
* rc-update add sshdx default

Why do you want an sshdx?

* change contiguration to support certificate authentication (don't understand how to do this)
* change configuration to disable password authentication (don't know how to do this either)"
This you do by:
Add the lines:
ChallengeResponseAuthentication no
GSSAPIAuthentication no
RSAAuthentication yes
PubkeyAuthentication yes
_________________
http://xbmodder.us/
Back to top
View user's profile Send private message
sschlueter
Guru
Guru


Joined: 26 Jul 2002
Posts: 578
Location: Dortmund, Germany

PostPosted: Sun Sep 16, 2007 10:05 pm    Post subject: Reply with quote

I think it would be better to use only one instance of the ssh server.

I guess that you want to allow password authentication on your local network and just want to make sure that no password authentication is allowed for connetions made from the internet so that no passwords can be bruteforced.

Then you could configure the ssh server to disallow password authentication globally and use the "Match" keyword in sshd_config to allow password authentication if the connection is from the local network.

On my system, it's sufficient to set both "PasswordAuthentication" and "UsePAM" to "no" to disallow password authentication.
Back to top
View user's profile Send private message
sschlueter
Guru
Guru


Joined: 26 Jul 2002
Posts: 578
Location: Dortmund, Germany

PostPosted: Sun Sep 16, 2007 10:30 pm    Post subject: Reply with quote

Here's a working sshd_config file that globally disallows password authentication but allows it for the trusted network:

Code:
Protocol 2
PasswordAuthentication no
UsePAM no
X11Forwarding yes
Subsystem       sftp    /usr/lib/misc/sftp-server
Match Address 192.168.1.*
        PasswordAuthentication yes
Back to top
View user's profile Send private message
schmeggahead
Guru
Guru


Joined: 25 Feb 2003
Posts: 314
Location: Columbus, Ohio

PostPosted: Sun Sep 16, 2007 10:44 pm    Post subject: Reply with quote

Thanks for the config updates - I would rather have one instance of ssh that is smart enough to do what I want (and now thanks to you, I'm smart enough to tell it how to be smart enough to do what I want. :D )

I do want to avoid the brute force password attack that you mention.

I'm still battling expat hades which got me into the full system rebuild situation in the first place ( well my own stupidity got me there unmerging python to get around a block with emerge -e system <ouch> ) At least I only nuked one of my gentoo boxes.
So I thought a full system rebuild would not encounter expat problem - WRONG - I sure hope newbies have a clear path in the install doc or there won't be any new gentoo systems out there). oy.

Update: I have returned from expat hades and emerged victorious. Revdep-rebuild now actually gives me a good completion.
So as long as the newbies do revdep-rebuild, they are good to go.

Still failing to use certificate authentication though.
Built the certificate in Puttygen and saved it first in the openssh version and then the default. Neither seems to work. I also edited .ssh/authorized_keys to have the rsa certificate be one line and no other lines in the file.

Punting and creating the certificate in ssh.

OK - I get a big DUH for not using the copy and paste screen in Puttygen to copy and paste into authorized keys file.
All is working for certificate authentication.
Moving forward with the config changes.
Back to top
View user's profile Send private message
schmeggahead
Guru
Guru


Joined: 25 Feb 2003
Posts: 314
Location: Columbus, Ohio

PostPosted: Wed Sep 19, 2007 12:30 am    Post subject: Reply with quote

So a visit to my local Panera confirmed - certificate only outside my network.

Way cool. X works (maybe a little slowly) and PSFTP worked like a charm.

cool. 8) 8) 8)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum