You are not logged in.

#1 2010-01-05 19:56:22

f4hy
Member
From: Pittsburgh Pa
Registered: 2009-02-08
Posts: 55

What is a good way to make key only ssh authentication practical

I am looking for some advice about ssh key management.

Basically all work I do I ssh into my desktop at home. I store everything there and being able to SSH in is amazing that I can work from anywhere. I started noticing that my desktop was under constant brute force ssh attacks so I decided to remove password authentication. (I am aware of stuff like port knocking but that seems even less convenient)

Now key authentication is great as long as I am on my netbook, but if I want to use a a friend or family's computer I can no longer access my desktop. One solution is to keep a private key on a flash drive so I can use it anywhere, but I always worry that installing the same private key everywhere I go is not very secure in case I forget to remove it when I am done. Also physically losing the flash drive worries me.

The other solution I have been using is to have a box at work able to access my desktop with keys and then I ssh into it and then hop again to my desktop. This allows me to scp a newly generated public key to my desktop if I want to add a machine but is cumbersome.

I am just curious how other users handle situations like this. Any clever solutions?

Offline

#2 2010-01-05 20:00:46

rebugger
Member
From: Germany
Registered: 2007-10-28
Posts: 229

Re: What is a good way to make key only ssh authentication practical

Another hint: change ssh-port to something different than 22.
I did this on my webserver and the bruteforce-attacks (made by bots) went from 500/day to 20/week.

And by the way: choose a good and long password.

Offline

#3 2010-01-06 06:32:36

seiichiro0185
Member
From: Leipzig/Germany
Registered: 2009-04-09
Posts: 226
Website

Re: What is a good way to make key only ssh authentication practical

For accessing my Machines from (Windows-)Machines I use the portable putty client from www.portableapps.com It's on my flash drive along with a private key (that has a strong password so losing it won't be that dramatic). It runs completely off the flash drive and doesn't store anything on the Machine, so the key always stays only on the flash drive. Unfortunalety I haven't found a solution like this for linux machines so far (But most people where I would need this are running windows on their machines anyways).

And I also recommend changing the ssh-port to something different than 22 like rebugger said. It really reduces the brute-force attacks since most bots attack only port 22


My System: Dell XPS 13 | i7-7560U | 16GB RAM | 512GB SSD | FHD Screen | Arch Linux
My Workstation/Server: Supermicro X11SSZ-F | Xeon E3-1245 v6 | 64GB RAM | 1TB SSD Raid 1 + 6TB HDD ZFS Raid Z1 | Proxmox VE
My Stuff at Github: github
My Homepage: Seiichiros HP

Offline

#4 2010-01-06 07:04:01

Zeist
Arch Linux f@h Team Member
Registered: 2008-07-04
Posts: 532

Re: What is a good way to make key only ssh authentication practical

Also, besides from changing the port I would set it so that it ignores login attempts from an IP for a minute or so if it's failed to login once, that tends to also help discourage people.


I haven't lost my mind; I have a tape back-up somewhere.
Twitter

Offline

#5 2010-01-06 15:55:38

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: What is a good way to make key only ssh authentication practical

1. +1 Change your ssh port!!
2. I have a flash drive with two partitions -- first is vfat partition with docs and some portable apps installed as seiichiro0185 said -- putty with the strong private key. Second partition is larch install so I can boot into arch and work from the flash drive with my usual tools if possible -- then I have all my normal ssh configs, keys and have ssh-agent running for convenience -- and no tracks left on the host machine. Someone who got ahold of your flash drive would really need to be knowledgeble to get your private keys......which they still have to crack the passphrase on anyways smile Just don't accidentally leave your public key on the flash drive, too!
3. On your server also make sure root login is disabled.

Scott

Offline

#6 2010-01-07 04:10:11

delerious010
Member
From: Montreal
Registered: 2008-10-07
Posts: 72

Re: What is a good way to make key only ssh authentication practical

I've just been leaving my ssh key in my gmail account with a nice long pass-phrase and I rotate it on a weekly basis. And my servers / VMs all running with LPK patched openssh, so my key's stored in LDAP, which kills all key deployement issues i may have.

One thing though that I've also gotten into the habit of doing with any externally facing ssh, is setting up connection throttling for ssh. By default, I've got iptables ( via shorewall ), limitting ssh connections per IP per minute to a low number to alleviate brute force notifications in my log files.

Most "real" users don't try to establish all that many ssh connections at once anynow, so this doesn't cause a problem. And "power" users ( me ), have SSH configured to reuse the open socket to the host, so the firewall's not seeing any new connections being established anyhow.

Offline

#7 2010-01-07 06:52:51

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: What is a good way to make key only ssh authentication practical

Allow only certain usernames, and change your port as said. The latter should filter out 99,99% of the bots that scan SSH ports. Key-based authentication is always preferable to password-based, but it can indeed be very inconvenient if you have to access the system from outside your LAN - exposing your key (especially if you did not set a password on it, like some people like to do) is a security risk by itself.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#8 2010-01-07 09:20:27

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: What is a good way to make key only ssh authentication practical

Zeist wrote:

Also, besides from changing the port I would set it so that it ignores login attempts from an IP for a minute or so if it's failed to login once, that tends to also help discourage people.

I'd do it for a day or so - but don't know where! A quick google told me about fail2ban but isn't there something one can tweak in /etc/ssh/*.conf?


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

#9 2010-01-07 10:03:54

theDOC
Member
From: Aachen, Germany
Registered: 2009-06-18
Posts: 50

Re: What is a good way to make key only ssh authentication practical

maybe you can setup a "guest" account with a 2nd key, that you can take to your friends. The guest account has no rights other than being able to su to your real account. Or, you can setup a 2nd key in your main account, that is protected by a strong password.

Offline

#10 2010-01-07 10:54:49

e_tank
Member
Registered: 2006-12-21
Posts: 80

Re: What is a good way to make key only ssh authentication practical

i've done the following simple steps to help thwart ssh brute force attacks on my machine (password auth):
1. changed the default port
2. made sure root login was disabled
3. only allow certain users
4. configured iptables with the script found on the arch wiki simple stateful firewall page, which contains a rule chain for ssh that checks if an ip has made >= 8 connections within 30 mins and if so blocks them out for 30 mins (it resets to 30 mins if they try and connect again during the original ban).  since iptables can't distinguish between successful/failed logins i bumped the connection count up a little but other than that my iptables config is nearly identical.

i haven't gotten any brute force ssh attempts, but then again i don't normally allow ssh connections outside my local network.  however, i have gotten ftp brute force attempts which have been thwarted by the same iptable rules that i use for ssh.

also, i haven't used it myself yet but you might want to check out denyhosts, which watches your sshd log for brute force attempts and automatically adds them to hosts.deny

Last edited by e_tank (2010-01-07 11:29:46)

Offline

#11 2010-01-07 12:00:15

Zeist
Arch Linux f@h Team Member
Registered: 2008-07-04
Posts: 532

Re: What is a good way to make key only ssh authentication practical

toad wrote:
Zeist wrote:

Also, besides from changing the port I would set it so that it ignores login attempts from an IP for a minute or so if it's failed to login once, that tends to also help discourage people.

I'd do it for a day or so - but don't know where! A quick google told me about fail2ban but isn't there something one can tweak in /etc/ssh/*.conf?

I don't know if there is anything in sshd itself that can do it, I use fail2ban.


I haven't lost my mind; I have a tape back-up somewhere.
Twitter

Offline

#12 2010-01-07 13:25:37

delerious010
Member
From: Montreal
Registered: 2008-10-07
Posts: 72

Re: What is a good way to make key only ssh authentication practical

Hmm pretty sure ssh doesn't have such a facility. Closest thing I could think of would be uaccount disabling via PAM after failed passwords-or-security, but that's really not a good thing when people are doing blind brute force attempts big_smile

Offline

#13 2010-01-07 13:44:05

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: What is a good way to make key only ssh authentication practical

Apparently it isn't necessary anyway. I've put my ssh on a different port an have had NO attacks for over 24 months smile It is either my magic port or the router has a damn fine firewall...


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

Board footer

Powered by FluxBB