2

I have this interesting issue where I am unable to ssh into my server running bionic beaver unless I ping it first. I ran into this issue on another server about a year ago running ubuntu 16, but I fixed it and didn't keep any notes on the problem because I thought it was a weird, one off issue. In that situation, I wasn't able to access any of the services, such as ssh and web, until I had a constant ping going. The kicker is that one of my other Ubuntu servers is able to ssh into this machine without any issues. My workstation is an iMac running High Sierra, and yes, UFW has been disabled.

root@server:/var/log# ufw status
Status: inactive

root@server:/var/log# aptitude search ssh
p   erlang-ssh           - Erlang/OTP implementation of SSH protocol                                                                                      
p   libssh-4             - tiny C SSH library (OpenSSL flavor)                                                                                            
p   libssh-dev           - tiny C SSH library. Development files (OpenSSL flavor)                                                                         
p   libssh-doc           - tiny C SSH library. Documentation files                                                                                        
p   libssh-gcrypt-4      - tiny C SSH library (gcrypt flavor)                                                                                             
p   libssh-gcrypt-dev    - tiny C SSH library. Development files (gcrypt flavor)                                                                          
i   openssh-client       - secure shell (SSH) client, for secure access to remote machines                                                                
i   openssh-server       - secure shell (SSH) server, for secure access from remote machines                                                              
i   openssh-sftp-server  - secure shell (SSH) sftp server module, for SFTP access from remote machines                                                    
i   ssh                  - secure shell client and server (metapackage)                                                                                   
v   ssh-client           -                                                                                                                                
i   ssh-import-id        - securely retrieve an SSH public key and install it locally                                                                     
v   ssh-server           -                       

root@server:/var/log# aptitude show ssh
Package: ssh                      
Version: 1:7.6p1-4ubuntu0.2
State: installed
Automatically installed: no
Priority: optional
Section: net
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: all
Uncompressed Size: 106 k
Depends: openssh-client (>= 1:7.6p1-4ubuntu0.2), openssh-server (>= 1:7.6p1-4ubuntu0.2)
PreDepends: dpkg (>= 1.17.5)

imac:~ iMac$ ssh -vvv administrator@server
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to server port 22.
ssh: connect to host server port 22: Operation timed out

Any thoughts on why I would have difficulties getting into this machine from my Mac?

15
  • I have another Ubuntu server setup that is able to ssh into it without any issues. In fact I was using that server to get the details I included in my initial post. – wolfenstein87 Feb 28 '19 at 21:19
  • If you add the host and IP address to the /etc/hosts on the Mac, does it still require you to ping the server before you can ssh to it? – Terrance Feb 28 '19 at 21:26
  • Modifying /etc/hosts doesn't make any difference on the client side. Still receive a time out. – wolfenstein87 Feb 28 '19 at 21:28
  • That's what is throwing me off here since ssh should be the same across the systems as far as the protocol itself goes. Since your other Ubuntu server can ssh to it without a problem is why I was thinking the Mac might be. Can the Mac ssh to the other Ubuntu host without pinging it? – Terrance Feb 28 '19 at 21:31
  • Yep. I have two other Ubuntu machines running and can connect to them with no problems. Trust me, this issue is mind boggling and I had fixed it on a demo server I setup about a year ago, I just have no clue what I modified on the server to fix the problem. – wolfenstein87 Feb 28 '19 at 21:34
0

You didn't clarify whether or not this happens locally on same lan, subnet or something else. If this happens locally it could be your SSH request doesn't reach the host due to bad switching or bad numbers in an ARP table somewhere. I would make sure to clear whatever tables client side and on hardware along the way. Make sure it's not networking before spending too much time debugging the server. (note: I really wanted to write this as a comment, but that wasn't possibly)

5
  • All of the connections are on the local LAN. I have deleted the arp entries for this machine on my local Mac, and on our Firewall. We only have 1 managed switch, of which I don't have admin access. I'll get with the person who manages that device later to see about deleting some arp entries. – wolfenstein87 Mar 1 '19 at 14:10
  • Try running tcpdump on the server while running the SSH command from your client to check if the server receives any packages from your mac. If the package never reaches the server you can rule out server issue. If it reaches you have to do some server debugging. – csensitive Mar 1 '19 at 18:12
  • Good call. I ran tcpdump -s 0 <ipAddress> and the server sees the connection attempts. It could be a DNS issue as I'm seeing a DNS name that hasn't been used in a long time. – wolfenstein87 Mar 1 '19 at 19:40
  • Fixed the DNS thing, but still no connection. Ubuntu server sees the connection attempts from my local machine, local machine gets a time out. – wolfenstein87 Mar 1 '19 at 20:07
  • Ended up being network related. Glad it worked out in the end. – csensitive Mar 1 '19 at 22:19
0

Well, I am the dumb. It turns out that I used the wrong subnet CIDR when I was configuring the IP address, I used 24 instead of 23 so only machines with our .2.x subnet were able to connect and anything outside of that got denied. I wasn't able to make the connection as to why certain machines wer able to connect to it and others weren't until my supervisor tried it from one of his servers and asked "could it be that only certain subnets can connect". Light bulb went off, I changed the subnet value, and now I can connect.

Thanks everyone for attempting to help me. TL:DR, check your subnet in netplan and make sure it's correct. @wolfenstein87 are the dumb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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