0

Is it possible to gain access to a router by SSHing into it. I understand that you can ssh into a specific server or machine with SSH, but can you do the same thing with a router if you know the router's IP address?

5
  • 1
    Hello, welcome to Information Security. This question is either a 'how to break into X' question, or not about security altogether, hence off-topic here. Given the question and comments on the different answers here, I get that you don't have much experience with network infrastructures and operations. I would suggest that you look more in detail into your specific router manual, which should help you configure it and know if SSH is actually enabled on it, and how you can operate it.
    – M'vy
    Commented Sep 4, 2018 at 9:51
  • @M'vy What's with the need to be condescending? His question may very well be related to security, wanting to use ssh to understand a router more thoroughly. You shouldn't be striving for such out of reach efficiency on these sites anyway. This kind of mentality ruins the atmosphere for nearly everyone.
    – Tycholiz
    Commented Sep 27, 2020 at 3:12
  • @Tycholiz I didn't find M'vy comment condescending at all, quite helpful actually. You can clearly see from OP comments on answers that they are asking step-by-step instructions to connect to their router via ssh (with multiple follow-up questions in the comments), and that's definitely off-topic here. There's zero security-related content and thus a better fit for SuperUser or networking.SE. Commented Nov 23, 2020 at 17:30
  • @soxwithMonica I see what you are saying, but something I've noticed quite a bit on these sites is that people come here looking for an answer and are quickly turned off the community because those more familiar with the platform "put them in their place" about what is and isn't appropriate. I've heard this time and time again that it contributes to a toxic and elitist environment that discourages people from asking and even continuing on with their learning. Since I see that as the worst thing that could happen from asking a question, I encourage people to be helpful regardless.
    – Tycholiz
    Commented Nov 23, 2020 at 17:46
  • 1
    @Tycholiz and I see what are you saying too (i partially agree, but a bit of "elitism" is what keeps the site useful and clean), I just tought that this wasn't the case. Commented Nov 23, 2020 at 17:55

3 Answers 3

1

Yes, you can.

Assuming that the router runs a SSH server, you can SSH in to the router, you can gain control of both the router and the network that the router is controlling.

7
  • what credentials do you need to do this? Commented Sep 4, 2018 at 3:55
  • and could the same logic apply to SSHing into your VPN using the IP address they provide you? Commented Sep 4, 2018 at 3:58
  • 1
    umm, no. A properly configured network will never allow access to network infrastructures to a VPN customer.
    – user185840
    Commented Sep 4, 2018 at 4:03
  • same applies for my personal router network? What about if ports are being forwarded? Commented Sep 4, 2018 at 4:07
  • 3
    @user185840: That isn't true at all.
    – user173641
    Commented Sep 4, 2018 at 9:36
2

In order to establish a SSH connection your router needs to be running a SSH service, usually listening on port 22.

You will not be able to access it otherwise, because the router is not expecting to have a SSH connection.

Not every router will allow you that. Actually, for security reasons many do not. There are always workarounds, such as install open-source firmwares on the router.

If you are using an UNIX like OS, and if your router is running a SSH service, you might want to try :

ssh <username>@<hostname/ip_address> 

Just to conclude, do not count on your router to accept a SSH connection out of the box.

1
  • what would the hostname be for my router and where would I find it? I am using a Netgear router. Commented Sep 4, 2018 at 4:58
1

If you want to SSH into a router, first ip a to find your local ip (The one under one of the UP interfaces), starting with 192.168..
Run a nmap scan like: nmap -sP 192.168.2.1/24 to find all hosts on the network (considering your local ip is starting with 192.168.2.). Once you find the router IP, then do nmap -sV -T4 -O -F --version-light <target> to find the SSH port.

2
  • Do I go on google search and type in "whats my ip address"? And then that public IP address is my routers IP? Or is it something like 192.168.1.1? Commented Sep 4, 2018 at 5:00
  • @CodyRutscher You have to type in ipconfig (or if your using linux ifconfig) to find your Default Gateway. Once you found your Default Gateway you can switch 192.168.2.1/24 with 192.168.1.1/24 or whatever your default gateway is. (**MAKE SURE YOU KEEP /24 OR IT WON'T WORK!)
    – zucc0nit
    Commented Sep 4, 2018 at 5:04

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