ubuntu 新系统初始化

cp -r/etc/apt/sources.list/etc/apt/sources.list.bak

sed -i's#http://deb.debian.org#https://mirrors.aliyun.com#g' /etc/apt/sources.list

sudo apt update

sudo apt install openssh-server

sudo systemctl status ssh

/etc/init.d/ssh start

sudo echo " PermitRootLogin yes "  >>  /etc/ssh/sshd_config

sudo ufw allow ssh

sudo systemctl disable --now

sudo systemctl enable --now ssh

cat ~/home/id_rsa.pub >> ~/.ssh/authorized_keys

### 更新软件包索引

sudo apt update

### 安装 ssh 服务

sudo apt install openssh-server

### 查看 ssh 状态

sudo systemctl status ssh

- 如果运行状态不为active(running),需要手动开启,命令为:

/etc/init.d/ssh start

### 修改 ssh 配置

sudo vim /etc/ssh/sshd_config

# 将PermitRootLogin prohibit-password那一行修改为PermitRootLogin yes

# 去掉前面的#号将port 22前面的#去掉

### 检查防火墙

sudo ufw allow ssh

### 重新注册ssh服务并附带立马启动

sudo systemctl disable --now ssh

sudo systemctl enable --now ssh

### ssh免密登录设置方法

cat ~/home/id_rsa.pub >> ~/.ssh/authorized_keys

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容