Linux學(xué)習(xí)
一、使用PuTTY遠(yuǎn)程連接Linux
二、使用xshell連接Linux
三、PuTTY密鑰認(rèn)證
四、xshell密鑰認(rèn)證
一、使用putty遠(yuǎn)程連接Linux
打開putty后,輸入ip地址,連接類型為SSH,默認(rèn)端口為22;點擊Open即可進(jìn)入;也可以保存會話,在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、在左側(cè),用戶身份驗證,輸入用戶名和密碼,點擊確定然后點擊連接;
image.png
4、putty和xshell都可以在相應(yīng)的位置外觀、字體、配色方案等。xshell支持多窗口會話
image.png
三、PuTTY密鑰認(rèn)證
1、密鑰認(rèn)證和密碼認(rèn)證都是一種認(rèn)證方式;密鑰認(rèn)證需要的密鑰對(一個加密,一個解密);服務(wù)器上存放公鑰;點擊puttyGEN--generate--晃動鼠標(biāo)--生成隨機字符串
image.png
2、在root下創(chuàng)建.ssh目錄,賦予該目錄700權(quán)限,在此目錄下創(chuàng)建authorized_keys文件用于存放公鑰;將上一步的公鑰復(fù)制到authorized_keys下,按esc,:wq保存退出即可。
[root@localhost ~]# mkdir /root/.ssh
[root@localhost ~]# chmod 700 /root/.ssh
[root@localhost ~]# vi /root/.ssh/authorized_keys
3、關(guān)閉防火墻
[root@localhost ~]# getenforce //獲取selinux狀態(tài)
Enforcing //強制執(zhí)行
[root@localhost ~]# setenforce 0 //臨時關(guān)閉
[root@localhost ~]# !g //重復(fù)最近一次g開頭的命令
getenforce
Permissive
[root@localhost ~]#
可以編輯/etc/selinux/config文件,永久關(guān)閉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 //三種狀態(tài):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密鑰認(rèn)證
1、在工具——新建用戶密鑰生成向?qū)В乱徊降綇?fù)制公鑰,完成向?qū)А?fù)制的公鑰粘貼到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 ~]#