3

I see there are continuous attempts to login into my computer via ssh using usernames, like joan florin root from 60.169.22.118,

-how can I forbid ssh access and only allow it to users with specific key.

-or for now how can I block traffic from that specific ip.

-or any other ways of securing more the connection to my home network.

I do have vpn, but the problem is, the service goes down every now and then, so ssh is the only sure, or constant service that can tell me when my server is up and running at home.

3 Answers 3

4

Edit your /etc/ssh/sshd_config

Add a line like

AllowUsers kmassada

Now only that user will be allowed to ssh in. Also, I run ssh on an unusual port, not 22, and this bumps off most would-be intruders.

And/or

PasswordAuthentication no

Which means you'll have to have an authorized key to connect. I'd suggest

PermitRootLogin no

too. See man sshd_config for these details.

4
  • Also, /etc/hosts.deny might be the place if you want to knock off that single IP. Sep 4, 2012 at 16:41
  • I thought of using ssh with a different port, but how do you do that? I map port 22 on my external to port 22 on my local machine? so on the client side, how would I specify a specific port while ssh'in into machine.
    – kmassada
    Sep 4, 2012 at 18:29
  • okay so I found that you can ssh -p XXXX, to specify a port number. A little more reading and my environment should be a bit more secure.
    – kmassada
    Sep 4, 2012 at 18:46
  • 1
    yeah, and the best thing to do IMO is to set up ~/.ssh/config. This way you can set an alias for a particular host and supply as much or little info as you need. e.g. you can then go ssh myserver and it will put in port, IP/host, user... Sep 4, 2012 at 18:56
0

Install a tool like denyhosts. It will block those IPs automatically (It tracks login failures and then blocks the IPs). So be careful. Make sure Your IP is on /etc/hosts.allow.

0

In addition to PasswordAuthentication no as suggested, you need to allow access by key. Check this:

http://yourtoolbox.blogspot.com/2012/08/ssh-connection-with-no-password.html

1
  • Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – guntbert
    Aug 3, 2013 at 18:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .