翼度科技»论坛 云主机 LINUX 查看内容

NTP/SSH 服务器

8

主题

8

帖子

24

积分

新手上路

Rank: 1

积分
24
NTP 服务器

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

NTP 服务器:配置 NTP 服务器(NTPsec)
  安装NTPsec 并配置 NTP 服务器以进行时间调整。NTP 使用 123/UDP。
[1]  安装和配置 NTPsec。
  1. root@dlp:~# apt -y install ntpsec
  2. root@dlp:~# vi /etc/ntpsec/ntp.conf
  3. # line 24 : if you use your own NTP servers only and also
  4. # pool entries are a few, change number of value below or comment out the line
  5. #tos minclock 4 minsane 3
  6. # line 34 : comment out default settings and add NTP server pool you like to use
  7. # * OK to keep default if you do not have specific requirements
  8. #pool 0.ubuntu.pool.ntp.org iburst
  9. #pool 1.ubuntu.pool.ntp.org iburst
  10. #pool 2.ubuntu.pool.ntp.org iburst
  11. #pool 3.ubuntu.pool.ntp.org iburst
  12. # Use Ubuntu's ntp server as a fallback.
  13. #server ntp.ubuntu.com
  14. pool ntp.nict.jp iburst
  15. # verify status
  16. root@dlp:~# ntpq -p
  17.      remote           refid      st t when poll reach   delay   offset   jitter
  18. ===============================================================================
  19. ntp.nict.jp     .POOL.          16 p    -  256    0   0.0000   0.0000   0.0001
  20. -ntp-a3.nict.go. .NICT.           1 u    -   64    1  17.4839  -1.6838   1.1843
  21. +ntp-b3.nict.go. .NICT.           1 u    -   64    1  20.2276  -0.4035   1.2985
  22. +ntp-b2.nict.go. .NICT.           1 u    -   64    1  20.1772  -0.3506   1.1771
  23. *ntp-k1.nict.jp  .NICT.           1 u    -   64    1  13.3053   0.1693   1.2011
  24. -ntp-a2.nict.go. .NICT.           1 u    -   64    1  16.4007  -1.2824   1.2209
  25. ntp-a2.nict.go. .INIT.          16 u    -   64    0   0.0000   0.0000   0.0001
  26. 2001:ce8:78::2  .INIT.          16 u    -   64    0   0.0000   0.0000   0.0001
  27. 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。
  1. root@dlp:~# apt -y install chrony
  2. root@dlp:~# vi /etc/chrony/chrony.conf
  3. # line 20 : comment out default settings and add NTP server pool you like to use
  4. # * OK to keep default if you do not have specific requirements
  5. #pool ntp.ubuntu.com        iburst maxsources 4
  6. #pool 0.ubuntu.pool.ntp.org iburst maxsources 1
  7. #pool 1.ubuntu.pool.ntp.org iburst maxsources 1
  8. #pool 2.ubuntu.pool.ntp.org iburst maxsources 2
  9. pool ntp.nict.jp iburst
  10. # add to last line : add network range you allow to receive time syncing requests from clients
  11. allow 10.0.0.0/24
  12. root@dlp:~# systemctl restart chrony
  13. # verify status
  14. root@dlp:~# chronyc sources
  15. MS Name/IP address         Stratum Poll Reach LastRx Last sample
  16. ===============================================================================
  17. ^- ntp-a3.nict.go.jp             1   6    17     1    -36us[  -36us] +/- 8587us
  18. ^- ntp-b3.nict.go.jp             1   6    17     1  -1399us[-1399us] +/-   10ms
  19. ^+ ntp-b2.nict.go.jp             1   6    17     0  -1167us[-1167us] +/- 9928us
  20. ^* 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]。
  1. root@client:~# systemctl status systemd-timesyncd
  2. *  systemd-timesyncd.service - Network Time Synchronization
  3.      Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled>
  4.      Active: active (running) since Fri 2024-04-26 05:52:41 UTC; 55s ago
  5.        Docs: man:systemd-timesyncd.service(8)
  6.    Main PID: 591 (systemd-timesyn)
  7.      Status: "Idle."
  8.       Tasks: 2 (limit: 4612)
  9.      Memory: 1.4M (peak: 2.0M)
  10.         CPU: 27ms
  11.      CGroup: /system.slice/systemd-timesyncd.service
  12.              +-- 591 /usr/lib/systemd/systemd-timesyncd
  13. root@client:~# vi /etc/systemd/timesyncd.conf
  14. # add to last line : set NTP server for your timezone
  15. NTP=dlp.srv.world
  16. root@client:~# systemctl restart systemd-timesyncd
  17. root@client:~# timedatectl timesync-status
  18.        Server: 10.0.0.30 (dlp.srv.world)
  19. Poll interval: 4min 16s (min: 32s; max 34min 8s)
  20.          Leap: normal
  21.       Version: 4
  22.       Stratum: 2
  23.     Reference: 3DCD7882
  24.     Precision: 1us (-24)
  25. Root distance: 11.184ms (max: 5s)
  26.        Offset: -296us
  27.         Delay: 192us
  28.        Jitter: 343us
  29. Packet count: 4
  30.     Frequency: +1.372ppm
复制代码
 
SSH 服务器

(01)密码认证

OpenSSH:密码身份验证
  配置 SSH 服务器以从远程计算机管理服务器。SSH 使用 22/TCP。
[1]  默认情况下,Ubuntu 上的 OpenSSH 服务器的密码身份验证处于启用状态, 因此,可以在不更改任何设置的情况下登录。此外 默认情况下,root 帐户禁止使用 [PermitRootLogin prohibit-password] 进行密码身份验证, 所以默认设置很好用。但是,如果您禁止全部root登录,请进行如下更改。
  1. root@dlp:~# apt -y install openssh-server
  2. root@dlp:~# vi /etc/ssh/sshd_config
  3. # line 33 : uncomment and change to [no]
  4. PermitRootLogin no
  5. root@dlp:~# systemctl restart ssh
复制代码
 
SSH 客户端:Ubuntu
  为 Ubuntu 配置 SSH 客户端。
[2]  安装 SSH 客户端。
  1. root@client:~# apt -y install openssh-client
复制代码
 
[3]  使用普通用户连接到 SSH 服务器。
  1. # ssh [username@hostname or IP address]
  2. root@client:~# ssh ubuntu@dlp.srv.world
  3. ubuntu@dlp:~$     # just logined
  4. The authenticity of host 'dlp.srv.world (10.0.0.30)' can't be established.
  5. ED25519 key fingerprint is SHA256:6wnWGpzjyIur7FRtJi3sbyGj3JolsRW1sEWC4tNM9ao.
  6. This key is not known by any other names.
  7. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
  8. Warning: Permanently added 'dlp.srv.world' (ED25519) to the list of known hosts.
  9. ubuntu@dlp.srv.world's password:
  10. Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-31-generic x86_64)
  11. .....
  12. .....
复制代码
 
[4]  可以通过向 ssh 命令添加命令在远程主机上执行命令。
  1. # for example, open [/etc/passwd] on remote host
  2. ubuntu@client:~$ ssh ubuntu@dlp.srv.world "cat /etc/passwd"
  3. ubuntu@dlp.srv.world's password:
  4. root:x:0:0:root:/root:/bin/bash
  5. daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
  6. bin:x:2:2:bin:/bin:/usr/sbin/nologin
  7. sys:x:3:3:sys:/dev:/usr/sbin/nologin
  8. sync:x:4:65534:sync:/bin:/bin/sync
  9. games:x:5:60:games:/usr/games:/usr/sbin/nologin
  10. man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
  11. .....
  12. .....
复制代码
 
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

 

来源:https://www.cnblogs.com/nc086/p/18176659
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

上一篇: DNS/DHCP 服务器

下一篇: 安装 Ubuntu

举报 回复 使用道具