Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

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.

share|improve this answer
    
Also, /etc/hosts.deny might be the place if you want to knock off that single IP. –  artfulrobot Sep 4 '12 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 '12 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 '12 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... –  artfulrobot Sep 4 '12 at 18:56

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.

share|improve this answer

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

share|improve this answer
    
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 '13 at 18:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.