天天看點

linux學習筆記-第一課-linux的曆史,安裝linux,遠端連接配接

一、Linux 的曆史

①創始人:Linus Torvalds(林納斯·托瓦茲)

②釋出時間:1991年10月5日

③核心:kernel

④衍生版本:常見的Ubuntu、RedHat、CentOS、Debain、Fedora、SuSE、Linux Mint、Gentoo、OpenSUSE、StartOS、Mandrake、FreeBSD等

⑤CentOS:(Community Enterprise  Operating System,中文意思是:社群企業作業系統)是Linux發行版之一,它是來自于Red Hat Enterprise Linux依照開放源代碼規定釋出的源代碼所編譯而成。由于出自同樣的源代碼,是以有些要求高度穩定性的伺服器以CentOS替代商業版的Red Hat Enterprise Linux使用。兩者的不同,在于CentOS并不包含封閉源代碼軟體。

⑥CentOS與紅帽關系:

    CentOS在2014初,宣布加入Red Hat。

    CentOS 加入紅帽後不變的是:

     1. CentOS 繼續不收費

     2. 保持贊助内容驅動的網絡中心不變

     3. Bug、Issue 和緊急事件處理政策不變

     4. Red Hat Enterprise Linux 和 CentOS 防火牆也依然存在

    變化的是:

     1. 我們是為紅帽工作,不是為 RHEL

     2. 紅帽提供建構系統和初始内容分發資源的贊助

     3. 一些開發的資源包括源碼的擷取将更加容易

     4. 避免了原來和紅帽上一些法律的問題

二、安裝虛拟機(VMware,Virtual box)

    安裝CentOS 6.5 安裝解說位址:點這裡

    配置網絡

[root@mylinux ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0      

  修改:ONBOOT=no  ==>  ONBOOT=yes  ==> 網卡是否開機啟動

        BOOTPROTO=dhcp  ==>  BOOTPROTO=static  ==> 網絡是如何擷取'dhcp'或者'static'

  增加:IPADDR=192.168.0.145  ==> IP位址

        NETMASK=255.255.255.0  ==> 子網路遮罩

        GATEWAY=192.168.0.1  ==> 網關位址

        DNS1=202.96.128.166  ==> DNS1位址

        DNS2=202.96.134.133  ==> DNS2位址

  退出儲存: esc : wq

  重新開機網絡服務:service network restart

  或者:使用絕對路徑 /etc/init.d/network restart

三、遠端連接配接

    軟體:putty,Xshell,SecureCRT

    通過秘鑰進行SSH加密連結:

    用PuttYgen生成秘鑰,并儲存好

# mkdir /root/.ssh/
# chmod 700 /root/.ssh/ <== 更改目錄權限
# vi /root/.ssh/authorized_keys <== 将秘鑰粘貼進來,退出儲存
# chmod 600 /root/.ssh/authorized_keys <==更改檔案權限
# setenforce 0 <== 臨時關閉selinux      

    永久關閉selinux

# vi /etc/selinux/config <==修改selinux配置      

    修改SELINUX=enforcing ==> SELINUX=disabled

注:selinux三個選項:enforcing,開啟SELINUX安全防護

                     permissive,關閉SELINUX安全防護,但是警告

                     disabled,不加載SELINUX安全防護

    在putty中SSH中Auth選項中添加私有秘鑰檔案位置

    擴充内容:服務端與用戶端ssh密鑰對聯機,無密碼聯機

    1 )首先需要在用戶端ssh-keygen生成密鑰對,公鑰與私鑰

[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
# 生成公共/私有密鑰對    
Enter file in which to save the key (/root/.ssh/id_rsa):
# 輸入儲存密鑰檔案中/root/.ssh/id_rsa
Enter passphrase (empty for no passphrase):
# 輸入密碼(無密碼為空)
Enter same passphrase again:
# 再次确認密碼
Your identification has been saved in /root/.ssh/id_rsa.
# 你的身份驗證儲存于/root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub.
# 你的公共密鑰儲存于/root/.ssh/id_rsa.pub
The key fingerprint is:
# 
91:cc:42:a3:69:4b:ba:0e:7a:14:a9:dd:66:12:c5:5d [email protected]
The key's randomart p_w_picpath is:
# 随機的圖像密鑰為:
+--[ RSA 2048]----+
|   . .o.E        |
|    o+.+ .       |
|   o= . =        |
|  ++ . . .       |
| o.+.   S        |
|. +.+            |
|...+             |
|.o.              |
|...              |
+-----------------+
[root@localhost ~]#      

    2 )将公鑰上傳到服務端中,公鑰儲存在 $HOME/.ssh/id_rsa.pub

[root@localhost ~]# scp ~/.ssh/id_rsa.pub [email protected]:/tmp
[root@localhost ~]# cat ~/tmp/id_rsa.pub > ~/.ssh/authorized_keys      

    3 )執行下面的指令,就可以不需要密碼就可以進行ssh無密碼登入

繼續閱讀