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.png
2、輸入IP地址
image.png
3、在左側,用戶身份驗證,輸入用戶名和密碼,點擊確定然后點擊連接;
image.png
4、putty和xshell都可以在相應的位置外觀、字體、配色方案等。xshell支持多窗口會話
image.png
三、PuTTY密鑰認證
1、密鑰認證和密碼認證都是一種認證方式;密鑰認證需要的密鑰對(一個加密,一個解密);服務器上存放公鑰;點擊puttyGEN--generate--晃動鼠標--生成隨機字符串
image.png
2、在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.png
login 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.png
Connecting 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 ~]#