openssh-server can't connect remotely

13,942

Usually when i need to access my Linux machine from ssh remotely, i just install ssh with sudo apt-get install ssh and by default it does what i need it to do. Connect via ssh from any PC.

Ubuntu also has their documentation on configuring openssh. https://help.ubuntu.com/community/SSH/OpenSSH/Configuring

  1. Install openssh, sudo apt-get install openssh-server
  2. Backup the default config, sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults then sudo chmod a-w /etc/ssh/sshd_config.factory-defaults
  3. Make any changes that you like, sudo gedit /etc/ssh/sshd_config. Check the openssh/ssh man page for instructions on configuring sshd_config
  4. Remember to restart the service to apply changes, sudo restart ssh or sudo systemctl restart ssh
  5. You can also make sure the ssh port is open on iptables. I almost never have to do this but if you need to. sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Share:
13,942

Related videos on Youtube

George
Author by

George

I like fun projects that push me to learn along the way.

Updated on September 18, 2022

Comments

  • George
    George almost 2 years

    I've got a fresh install of 16.04.3 desktop with openssh installed. I can connect to ssh on the same machine, but not across my internal network. ufw is inactive.

    The server host cannot be pinged by other hosts on my local network. It also cannot ping other hosts on the local network. The server host is able to be ping google.com, yahoo.com, etc.

    What am I missing to get ssh to work remotely?

    • Panther
      Panther almost 7 years
      what is the difference between " I can connect with ssh in term" and "not across my internal network" ? If you can connect , the ssh server is working and either you have something mis configured, ssh keys ? , or network problem such as port forwarding. Can not really tell from what you posted.
    • George
      George almost 7 years
      In term on the local machine I can ssh, from any other machine I cannot connect.
    • Panther
      Panther almost 7 years
      Hard to tell, if you can connect on the local machine the ssh server is working. It is most likely a problem with your firewall or you did not port forward. Start with ping and checking your firewall settings.
  • George
    George almost 7 years
    I tried adding the step 5. The first four were the same, but it did not seem to have any effect.
  • xR34P3Rx
    xR34P3Rx almost 7 years
    Just to clear this up, you are connecting "remotely" as in a local computer on your network, right? If so, make sure you can ping the machine you are trying to SSH into. Also on the linux machine with openssh, run in a terminal netstat -lt4 | grep ssh and make sure your machine is listening for SSH connections.
  • George
    George almost 7 years
    netstat -lt4 | grep ssh resulted in tcp 0 0 :ssh *: LiSTEN
  • xR34P3Rx
    xR34P3Rx almost 7 years
    ok, so you are fine on your machine. How are you connecting to the machine from the remote machine? Are you running this on a vm by any chance? Run ifconfig on your openssh machine and post the results, it might just be an IP issue. As well as the ip results of the remote. (if its windows, ipconfig.
  • George
    George almost 7 years
    wlan0 Link encap:Ethernet HWaddr 94:a1:a2:fa:cd:4b inet addr:192.168.1.86 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::bb09:7089:9590:9db/64 Scope:Link inet6 addr: 2602:30a:c7d3:4160:7a8c:f33:cf3:511d/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:112420 errors:0 dropped:0 overruns:0 frame:0 TX packets:75371 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:103416133 (103.4 MB) TX bytes:10985078 (10.9 MB)
  • George
    George almost 7 years
    I can only use the machine in question directly (keyboard/mouse). It is not a vm. The other host(s) are 192.168.1.87 and .79. One is Linux Mint, one Windows, I can ssh into the Mint host which is on the same wifi as the Ubuntu host. Neither Mint nor windows can ping the Ubuntu host, and the Ubuntu host can't ping either of them.
  • xR34P3Rx
    xR34P3Rx almost 7 years
    is your ubuntu machine set to static by any chance? are you able to ping your router? what kind of router do you have? its starting to sound like an issue with your firewall/router.
  • xR34P3Rx
    xR34P3Rx almost 7 years
    also, when you try to ping your mint and windows machines, what is the error message you get when pinging? is it destination unreachable or no route to host?
  • George
    George almost 7 years
    All hosts are using DHCP. I can ping my router from the Ubuntu host. I'm using the AT&T provided Uverse modem / router. When pinging out from Ubuntu to the Mint I get Destination Unreachable. To Windows the same, but Windows I wasn't expecting to respond. I have verified that I can ping from Windows to Mint without issue.
  • xR34P3Rx
    xR34P3Rx almost 7 years
    yet you can browse the internet just fine? Interesting... Could you try booting into a live USB/CD and ping your Mint machine that way? I wonder if maybe the NIC is just acting funny or it loaded the wrong drivers. It would also help if you happen to have a USB to Ethernet adapter you can try.
  • George
    George almost 7 years
    I'm guessing it's a driver issue, but I don't have other options so I'm giving up. I used the same install media on the same network on a different machine and it works flawlessly as described. I did a reinstall on the problem machine, and it still doesn't work the only difference is between the two is an extra step of loading a custom driver to get the networking going on the problem machine.
  • xR34P3Rx
    xR34P3Rx almost 7 years
    I'm sure there is a solution. Getting a different card shouldn't be a headache if you really want it.