0

I'm having difficulty starting samba on ubuntu

How can I see what ports are open on my machine?

root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# sudo netstat -ntlp | grep LISTEN
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      34237/systemd-resol
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      34174/sshd: /usr/sb
tcp6       0      0 :::22                   :::*                    LISTEN      34174/sshd: /usr/sb

root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~#
root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~#


https://ubuntu.com/tutorials/install-and-configure-samba

root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# sudo apt install samba

.....

root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# mkdir samba

root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# ls -l
total 12
drwxr-xr-x 2 root root 4096 Apr 23 18:01 abc
drwxr-xr-x 2 root root 4096 Apr 24 01:27 samba
drwxr-xr-x 3 root root 4096 Apr 23 17:26 snap


root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# cd samba/
root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~/samba# ls
root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~/samba# cd ..

root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# cd /root/samba
root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~/samba# ls
root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~/samba# cd ..


root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# sudo nano /etc/samba/smb.conf

(added lines suggested in that guide but adjusted the path line to the directory I created)
i.e.

[sambashare]
    comment = Samba on Ubuntu
    path = /root/samba
    read only = no
    browsable = yes



root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# sudo service smbd restart
root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# sudo ufw allow samba
Rules updated
Rules updated (v6)

( could use any username but used root)

root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# sudo smbpasswd -a root
New SMB password:
Retype new SMB password:
Added user root.

root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      51395/smbd
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      51395/smbd
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      34237/systemd-resol
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      34174/sshd: /usr/sb
tcp6       0      0 :::445                  :::*                    LISTEN      51395/smbd
tcp6       0      0 :::139                  :::*                    LISTEN      51395/smbd
tcp6       0      0 :::22                   :::*                    LISTEN      34174/sshd: /usr/sb
root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~#

I can SSH to that ubuntu server.. and I see 0.0.0.0:22 there.

When I go from another computer and do

$nmap -p22,445 157.111.214.123
Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-24 02:44 GMT Daylight Time
Nmap scan report for 157.111.214.123
Host is up (0.084s latency).

PORT    STATE    SERVICE
22/tcp  open     ssh
445/tcp filtered microsoft-ds

Nmap done: 1 IP address (1 host up) scanned in 2.43 seconds

(From what I understand "filtered" is as good as closed.. so rather than the port reply as closed it doesn't reply at all.. so some device e.g. a firewall is not responding to indicate that the port is open).

When I try to access the SAMBA share from (dare I say a windows machine), e.g. \\IP or net use \\IP, it doesn't work. But not surprising, 'cos nmap shows PORT 445 as not open.

barlop
  • 125
  • 1
  • 9
  • You don't need to use sudo at a root prompt. – user535733 Apr 24 '21 at 02:16
  • @user535733 I know, sometimes it was habit and sometimes I was using commands from a guide . I know sudo is redundant there, but it doesn't matter.. that has nothing to do with the problem – barlop Apr 24 '21 at 02:19
  • one suggestion i heard is maybe an isp is blocking SAMBA so could use scp sftp rsync – barlop Apr 24 '21 at 02:58
  • What is the output of `systemctl status smbd.service`? – Terrance Apr 24 '21 at 03:00
  • @Terrance looks like active to me https://gist.github.com/gartha1/3dd0977d03cdb9847ef2de9d27f3f4cc – barlop Apr 24 '21 at 03:04
  • Yep, it is. Are you trying to get to the Samba share externally? – Terrance Apr 24 '21 at 03:08
  • @Terrance Yes, it's a VPS, a VM hosted remotely (on the digitalocean cloud), (they call it a digitalocean droplet!) I don't have local access to it. – barlop Apr 24 '21 at 10:47
  • I don't think that Digital Ocean themselves would be blocking 445, but I don't know 100% since it is a service that I don't use. But you are correct that the `filtered` is a blocked port. It looks as though internally it would be working fine, but since it is remote to where you are at it is getting blocked. – Terrance Apr 24 '21 at 21:46
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/123402/discussion-between-barlop-and-terrance). – barlop Apr 24 '21 at 23:55

0 Answers0