Linux学习
一、使用PuTTY远程连接Linux
二、使用xshell连接Linux
三、PuTTY密钥认证
四、xshell密钥认证
一、使用putty远程连接Linux
打开putty后,输入ip地址,连接类型为SSH,默认端口为22;点击Open即可进入;也可以保存会话,在Saved Sessions处输入会话名称,点击save即可;
image.png
login as: root
root@192.168.220.128's password:
Last login: Sun Sep 9 10:37:34 2018 from 192.168.220.1
[root@localhost ~]#
二、使用xshell连接Linux
1、安装完xshell后,点击新建
image.png2、输入IP地址
image.png3、在左侧,用户身份验证,输入用户名和密码,点击确定然后点击连接;
image.png4、putty和xshell都可以在相应的位置外观、字体、配色方案等。xshell支持多窗口会话
image.png三、PuTTY密钥认证
1、密钥认证和密码认证都是一种认证方式;密钥认证需要的密钥对(一个加密,一个解密);服务器上存放公钥;点击puttyGEN--generate--晃动鼠标--生成随机字符串
image.png2、在root下创建.ssh目录,赋予该目录700权限,在此目录下创建authorized_keys文件用于存放公钥;将上一步的公钥复制到authorized_keys下,按esc,:wq保存退出即可。
[root@localhost ~]# mkdir /root/.ssh
[root@localhost ~]# chmod 700 /root/.ssh
[root@localhost ~]# vi /root/.ssh/authorized_keys
3、关闭防火墙
[root@localhost ~]# getenforce //获取selinux状态
Enforcing //强制执行
[root@localhost ~]# setenforce 0 //临时关闭
[root@localhost ~]# !g //重复最近一次g开头的命令
getenforce
Permissive
[root@localhost ~]#
可以编辑/etc/selinux/config文件,永久关闭selinux
[root@localhost ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing //三种状态:enforcing、permissive、disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes
are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
4、点击putty
image.pnglogin as: root
Authenticating with public key "rsa-key-20180909"
Passphrase for key "rsa-key-20180909":
Last login: Sun Sep 9 11:00:29 2018 from 192.168.220.1
root@localhost ~]#
四、xshell密钥认证
1、在工具——新建用户密钥生成向导,下一步到复制公钥,完成向导。将复制的公钥粘贴到authorized_keys下,保存退出即可。
[root@localhost ~]# vim /root/.ssh/authorized_keys
2、打开连接,属性--用户身份验证--方法--public key;用户密钥选择,输入加密时的密码;
image.pngConnecting to 192.168.220.128:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
WARNING! The remote SSH server rejected X11 forwarding request.
Last login: Sun Sep 9 11:31:44 2018 from 192.168.220.1
[root@localhost ~]#
网友评论