2022å¹´10æ21æ¥(æ¥æ¬æé)ãUbuntu 22.10 Kinetic Kuduããªãªã¼ã¹ããã¾ããã
主ãªå¤æ´ç¹ã«ã¤ãã¦ã¯ãªãªã¼ã¹ãã¼ããåç §ãã¦é ãããã®ã§ãããä¸è¬çãªã¦ã¼ã¶ã¼ã«ã¨ã£ã¦å½±é¿ããã§ããããã¤ã³ãã¯ãSSHãµã¼ãã¼ãsystemdã®Socket-Based Activationçµç±ã§èµ·åãããããã«ãªã£ãç¹ã§ãããã
ãã®å¤æ´ã¯ãSSHãµã¼ãã¼ã®å¾
ã¡åããã¼ããå¤æ´ãããå ´åã«å½±é¿ãããã¾ããå¾æ¥ã§ããã°/etc/ssh/sshd_configãç´æ¥æ¸ãæãã¦ãã¾ããããUbuntu 22.10ã§ã¯systemd.socketã®Unitãã¡ã¤ã«ãå¤æ´ããå¿
è¦ãããã¾ããããã©ã«ãã§ã¯/etc/systemd/system/sockets.target.wants/ssh.socket
ã¨ãããã¡ã¤ã«ã«ã以ä¸ã®è¨è¿°ãããã¦ãã¾ãããã®ListenStream
ããã¼ãã®æå®ã§ããã
[Unit] Description=OpenBSD Secure Shell server socket Before=sockets.target ConditionPathExists=!/etc/ssh/sshd_not_to_be_run [Socket] ListenStream=22 Accept=no [Install] WantedBy=sockets.target
å®ã¯/etc/systemd/system/sockets.target.wants/ssh.socket
ã¯/lib/systemd/system/ssh.socket
ã¸ã®ã·ã³ããªãã¯ãªã³ã¯ã§ãããã®ãã¡ã¤ã«ã¯openssh-serverããã±ã¼ã¸ãæä¾ãã¦ãããã¡ã¤ã«ã®ãããç´æ¥æ¸ãæããã®ã¯ããããããã¾ãããããã§Overrideãä½æãã¾ãã以ä¸ã®ã³ãã³ããå®è¡ãã¦ãã ããã
$ sudo systemctl edit ssh.socket
ããã¨/etc/systemd/system/ssh.socket.d/override.conf
ã¨ãããã¡ã¤ã«ãä½æãããããã¹ãã¨ãã£ã¿ãéãã¾ããããã«ä¸æ¸ãããããã©ã¡ã¼ã¿ãé©å®è¿½å ãã¦ãã ãããä»åã¯SSHã®å¾
ã¡åããã¼ããå¤æ´ãããã®ã§ã以ä¸ã®ããã«ListenStreamãæ¸ãæããã¨ããã§ããããä¾ãã°ããã©ã«ãã®22çªã®ãããã«2222çªã§å¾
ã¡åãããå ´åã¯ã以ä¸ã®ããã«ãã¾ãã
[Socket] ListenStream= ListenStream=2222
ãã¤ã³ãã¯ListenStream=
ã¨ãã空ã®è¡ã§ããsystemdã®Unitãã¡ã¤ã«ã§ã¯ããªã¹ãã¨ãã¦è§£éãããè¨å®(ããããã®ãService Unitã®ExecStartã¨ã)ã¯ãå¾ããè¨å®ãããã©ã¡ã¼ã¿ã追å ããã¦ããããã空ã®è¡ãæããã¨ã§æ¢åã®ã¨ã³ããªãåé¤ãã¦ããã®ã§ããããããã®è¡ãçç¥ããã¨ã22çªã¨2222çªã®ä¸¡æ¹ã§å¾
ã¡åããããã«ãªã£ã¦ãã¾ãã¾ãã
ãã¡ã¤ã«ãä¿åããããssh.socketãåèµ·åãã¦ãã ããã
$ sudo systemctl restart ssh.socket
ããã§SSHãµã¼ãã¼ã®å¾ ã¡åããã¼ããå¤æ´ã§ãã¾ããã