1 配置root用户密码
1.1 修改root用户的初始密码
sudo passwd
退出当前用户,使用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_config
server
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链接:
1.4 设置ssh免密码登陆
ssh localhost exit
输入密码登陆本机和退出本机
在进行了初次登录后,会在当前家目录用户下有一个.ssh文件夹,进入该文件夹下:
cd ~/.ssh/
使用rsa算法生成秘钥和公钥对:
ssh-keygen -t rsa
运行后一路回车就能够了,其中第一个是要输入秘钥和公钥对的保存位置,默认是在~/.ssh/。
而后把公钥加入到受权中:
cat ./id_rsa.pub >> ./authorized_keys
再次ssh localhost的时候就能够无密码登录了。