ubuntu 上配置开机自动启动ssh

一般安装了就会自动启动。但是各种rc.local, cron都测试了一下,还是这个systemd有效

使用 systemd 服务

创建文件

sudo nano /etc/systemd/system/custom-ssh.service

bash 复制代码
[Unit]
Description=Start SSH service at boot
After=network.target

[Service]
ExecStart=/usr/sbin/service ssh start
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

sudo systemctl enable custom-ssh.service

sudo systemctl start custom-ssh.service

相关推荐
多弗朗皮卡丘7 小时前
网络基础:数据链路层与其他协议或技术
linux·网络·tcp/ip
dingdingfish14 小时前
TLPI 第52章 读书笔记:POSIX Message Queues
linux·mq·ipc·posix·message·tlpi
wacsii14 小时前
【Linux进程(五)】进程控制全解析:从创建、终止、等待到程序替换
linux·服务器
七夜zippoe15 小时前
Nexent Linux 部署:用 deploy.sh
linux·服务器·docker·部署·ai智能体·nexent
去码头整点薯条9815 小时前
NFS服务器
linux·运维·服务器
蜗牛一步步往上爬16 小时前
第一章 初识Linux shell
linux·运维·服务器
拂拉氏16 小时前
【知识讲解】 Linux线程中锁的认识
linux·互斥锁
无足鸟ICT16 小时前
【RHCA+】系统调优配置文件
linux·服务器
七维大脑16 小时前
【开源自荐】7Shell:跨平台 SSH 运维客户端,把终端、SFTP、容器和 K8s 放进一个窗口
ssh·运维工具·开源工具·开源ssh