在 ubuntu 上启动 samba 困难

在 ubuntu 上启动 samba 困难

我在 ubuntu 上启动 samba 时遇到困难

我如何查看我的机器上打开了哪些端口?

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:~#

我可以通过 SSH 连接到该 ubuntu 服务器...并且在那里看到 0.0.0.0:22。

当我从另一台计算机执行

$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

(据我所知,“过滤”与关闭一样好..因此,端口回复不是关闭的,而是根本不回复..因此某些设备(例如防火墙)没有响应来表明端口是打开的)。

当我尝试从(我敢说是 Windows 机器)访问 SAMBA 共享时,例如\\IPnet use \\IP,它不起作用。但这并不奇怪,因为 nmap 显示端口 445 未打开。

相关内容