安装ssh环境

1 配置root用户密码

1.1 修改root用户的初始密码

sudo passwd

1.png

退出当前用户,使用root登录系统。算法

1.2 关闭防火墙

关闭防火墙shell

systemctl stop firewalld.service

开机不启动防火墙ubuntu

systemctl disable firewalld.service

查看防火墙状态vim

ufw status

inactive状态是防火墙关闭状态,active是开启状态。ssh

1.3 配置root用户远程链接

(注:server版ubuntu默认安装了ssh-server,若是未安装,请先安装)code

apt-get install openssh-server

修改sshd_configserver

vim /etc/ssh/sshd_config

找到blog

# Authentication:
LoginGraceTime 2m
PermitRootLogin without-password
StrictModes yes

改为get

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

而后重启SSH服务便可。it

重启事后经过shell链接:

2.png

1.4 设置ssh免密码登陆

ssh localhost
exit

输入密码登陆本机和退出本机

3.png

在进行了初次登录后,会在当前家目录用户下有一个.ssh文件夹,进入该文件夹下:

cd ~/.ssh/

使用rsa算法生成秘钥和公钥对:

ssh-keygen -t rsa

4.png

运行后一路回车就能够了,其中第一个是要输入秘钥和公钥对的保存位置,默认是在~/.ssh/。

而后把公钥加入到受权中:

cat ./id_rsa.pub >> ./authorized_keys

再次ssh localhost的时候就能够无密码登录了。

相关文章
相关标签/搜索