Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I think I just screwed up - I changed my VPS's SSH access port from 5252 to 48001, now I cannot login.

I changed it in the IPtables(/etc/sysconfig/iptables), I literally just changed the port number from 5252 to 48001, and then restarted my server. now, I also cannot access via port 5252...(obviously because I changed it, but I tried anyways)

How can I get into the VPS again? Other ports that are open are 80 and 21...Is there a way I can login from there with my root details?

Thank you

share|improve this question
1  
run nmap -sS yourserverIP and see what ports are open. Did you modify sshd_config file ? Did you change Port directive? –  val0x00ff Jul 23 '13 at 11:38
1  
Whilst I have great sympathy for your plight, and I hope Iain and Jenny D have helped you fix it, are you quite sure your username is entirely appropriate <grin>? –  MadHatter Jul 23 '13 at 12:26

2 Answers 2

up vote 3 down vote accepted

Unless you have some sort of out of band console access to the VPS then you'll have to contact your provider and get them to fix it for you.

What you should have done (you don't mention it) is change the Port directive in /etc/ssh/sshd_config as well as the port to allow in iptables.

You should have changed the port as above and restarted sshd (it doesn't drop your current connection) then added a line to the iptables configuration to allow the new port and restart iptables. Test the new connection works then remove the old connection details with the new connection and restart the services.

share|improve this answer
    
OK cool thanks for the tip...Do I need to restart the server everytime I make changes in the IPTABLES? Also, why doesn't the new port 48001 work? –  DextrousDave Jul 23 '13 at 11:46
    
@DextrousDave: Did you read my second paragraph ? –  Iain Jul 23 '13 at 11:47
    
@DextrousDave: service <servicename> restart –  Iain Jul 23 '13 at 11:50
    
oh ok i see..now I will just have to wait for my service provider to come back –  DextrousDave Jul 23 '13 at 12:41
2  
@DextrousDave: I think you need to speak to your manager about gerting some much needed education in Linux administration. Both you and your company will benefit immensely. –  Iain Jul 23 '13 at 13:10

At this point you need either physical access to the server, or access to a RIB/ILO/LOM interface which allows SSH. Or find a vulnerability in your webserver or FTP server that allows you to crack root on it.

A tip for the next time you want to change firewall rules remotely: Start by taking a copy of the original rules, and set an at or cron job to load the original rules within five minutes. If the new rules still allow you to login, you can then cancel the at/cron job.

share|improve this answer
    
yeah that is not a bad idea...if only I can get in again.How would I get a vulnerability in my ftp server? I knwo that port is open and I do have root's user details –  DextrousDave Jul 23 '13 at 11:44
    
The server has to be placed somewhere that somebody has physical access to, right? Talk to those people first. –  Jenny D Jul 23 '13 at 12:15
    
cool thanks for your help Jenny –  DextrousDave Jul 24 '13 at 13:19

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.