NTP/SSH 服务器
  VExS4Gg6g4KD 26天前 37 0

NTP 服务器

(01)配置 NTP 服务器(NTPsec)

NTP 服务器:配置 NTP 服务器(NTPsec)


  安装NTPsec 并配置 NTP 服务器以进行时间调整。NTP 使用 123/UDP。

[1]  安装和配置 NTPsec。

root@dlp:~# apt -y install ntpsec
root@dlp:~# vi /etc/ntpsec/ntp.conf
# line 24 : if you use your own NTP servers only and also 
# pool entries are a few, change number of value below or comment out the line
#tos minclock 4 minsane 3

# line 34 : comment out default settings and add NTP server pool you like to use
# * OK to keep default if you do not have specific requirements
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst

# Use Ubuntu's ntp server as a fallback.
#server ntp.ubuntu.com
pool ntp.nict.jp iburst 

# verify status
root@dlp:~# ntpq -p
     remote           refid      st t when poll reach   delay   offset   jitter
===============================================================================
 ntp.nict.jp     .POOL.          16 p    -  256    0   0.0000   0.0000   0.0001
-ntp-a3.nict.go. .NICT.           1 u    -   64    1  17.4839  -1.6838   1.1843
+ntp-b3.nict.go. .NICT.           1 u    -   64    1  20.2276  -0.4035   1.2985
+ntp-b2.nict.go. .NICT.           1 u    -   64    1  20.1772  -0.3506   1.1771
*ntp-k1.nict.jp  .NICT.           1 u    -   64    1  13.3053   0.1693   1.2011
-ntp-a2.nict.go. .NICT.           1 u    -   64    1  16.4007  -1.2824   1.2209
 ntp-a2.nict.go. .INIT.          16 u    -   64    0   0.0000   0.0000   0.0001
 2001:ce8:78::2  .INIT.          16 u    -   64    0   0.0000   0.0000   0.0001
 ntp-a3.nict.go. .INIT.          16 u    -   64    0   0.0000   0.0000   0.0001

 

(02)配置 NTP 服务器(Chrony)

NTP 服务器:配置 NTP 服务器(Chrony)


  安装 Chrony 并配置 NTP 服务器以进行时间调整。NTP 使用 123/UDP。

[1]  安装和配置 Chrony。

root@dlp:~# apt -y install chrony
root@dlp:~# vi /etc/chrony/chrony.conf
# line 20 : comment out default settings and add NTP server pool you like to use
# * OK to keep default if you do not have specific requirements
#pool ntp.ubuntu.com        iburst maxsources 4
#pool 0.ubuntu.pool.ntp.org iburst maxsources 1
#pool 1.ubuntu.pool.ntp.org iburst maxsources 1
#pool 2.ubuntu.pool.ntp.org iburst maxsources 2
pool ntp.nict.jp iburst 

# add to last line : add network range you allow to receive time syncing requests from clients
allow 10.0.0.0/24
root@dlp:~# systemctl restart chrony
# verify status
root@dlp:~# chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^- ntp-a3.nict.go.jp             1   6    17     1    -36us[  -36us] +/- 8587us
^- ntp-b3.nict.go.jp             1   6    17     1  -1399us[-1399us] +/-   10ms
^+ ntp-b2.nict.go.jp             1   6    17     0  -1167us[-1167us] +/- 9928us
^* ntp-a2.nict.go.jp             1   6     7     2   +264us[+1040us] +/-   10ms

 

(03)配置 NTP 客户端

NTP 服务器:配置 NTP 客户端


  配置 NTP 客户端。

  NTP 客户端 [systemd-timesyncd.service] 默认在 Ubuntu 上运行,因此很容易设置 NTP 客户端。

  顺便说一句,也可以使用 NTPsec 或 Chrony 作为 NTP 客户端。

  如果您使用它们,只需将 NTP 服务器设置为同步时间,不要设置接收来自其他主机的时间同步请求的权限。

[1]  配置 [systemd-timesyncd.service]。

root@client:~# systemctl status systemd-timesyncd
*  systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled>
     Active: active (running) since Fri 2024-04-26 05:52:41 UTC; 55s ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 591 (systemd-timesyn)
     Status: "Idle."
      Tasks: 2 (limit: 4612)
     Memory: 1.4M (peak: 2.0M)
        CPU: 27ms
     CGroup: /system.slice/systemd-timesyncd.service
             +-- 591 /usr/lib/systemd/systemd-timesyncd

root@client:~# vi /etc/systemd/timesyncd.conf
# add to last line : set NTP server for your timezone
NTP=dlp.srv.world
root@client:~# systemctl restart systemd-timesyncd
root@client:~# timedatectl timesync-status
       Server: 10.0.0.30 (dlp.srv.world)
Poll interval: 4min 16s (min: 32s; max 34min 8s)
         Leap: normal
      Version: 4
      Stratum: 2
    Reference: 3DCD7882
    Precision: 1us (-24)
Root distance: 11.184ms (max: 5s)
       Offset: -296us
        Delay: 192us
       Jitter: 343us
 Packet count: 4
    Frequency: +1.372ppm

 

SSH 服务器

(01)密码认证

OpenSSH:密码身份验证


  配置 SSH 服务器以从远程计算机管理服务器。SSH 使用 22/TCP。

[1]  默认情况下,Ubuntu 上的 OpenSSH 服务器的密码身份验证处于启用状态, 因此,可以在不更改任何设置的情况下登录。此外 默认情况下,root 帐户禁止使用 [PermitRootLogin prohibit-password] 进行密码身份验证, 所以默认设置很好用。但是,如果您禁止全部root登录,请进行如下更改。

root@dlp:~# apt -y install openssh-server
root@dlp:~# vi /etc/ssh/sshd_config
# line 33 : uncomment and change to [no]
PermitRootLogin no
root@dlp:~# systemctl restart ssh

 

SSH 客户端:Ubuntu


  为 Ubuntu 配置 SSH 客户端。

[2]  安装 SSH 客户端。

root@client:~# apt -y install openssh-client

 

[3]  使用普通用户连接到 SSH 服务器。

# ssh [username@hostname or IP address]
root@client:~# ssh ubuntu@dlp.srv.world
ubuntu@dlp:~$     # just logined
The authenticity of host 'dlp.srv.world (10.0.0.30)' can't be established.
ED25519 key fingerprint is SHA256:6wnWGpzjyIur7FRtJi3sbyGj3JolsRW1sEWC4tNM9ao.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'dlp.srv.world' (ED25519) to the list of known hosts.
ubuntu@dlp.srv.world's password:
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-31-generic x86_64)
.....
.....

 

[4]  可以通过向 ssh 命令添加命令在远程主机上执行命令。

# for example, open [/etc/passwd] on remote host
ubuntu@client:~$ ssh ubuntu@dlp.srv.world "cat /etc/passwd"
ubuntu@dlp.srv.world's password:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
.....
.....

 

SSH 客户端:Windows#1


  配置适用于 Windows 的 SSH 客户端。

[5]  获取适用于 Windows 的 SSH 客户端。此示例演示如何使用 Putty,如下所示。

 

(02)SSH 文件传输(Ubuntu)

(03)SSH 文件传输(Windows)

(04)SSH 密钥对认证

(05)仅限 SFTP + Chroot

(06)使用 SSH-Agent

(07)使用 SSHPass

(08)SSHFS 的使用

(09)SSH 端口转发

(10)使用并行 SSH

 

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: DNS/DHCP 服务器 下一篇: 安装 Ubuntu
  1. 分享:
最后一次编辑于 26天前 0

暂无评论

推荐阅读
  kZLEadpmxZsY   17天前   20   0   0 Linux
  tAaiqedz71Vf   17天前   26   0   0 Linux
  2sqDzWaoi9Ck   17天前   26   0   0 Linux
LVM
  XWcNkifzer3j   14天前   28   0   0 Linux