使用 亞馬遜雲 AWS 配置服務器
若是以前使用亞馬遜雲配置服務器沒有配置成功,那麼請按照下面的方式刪除掉實例
- 打開當前實例列表
![你本身的實例列表 你本身的實例列表](http://static.javashuo.com/static/loading.gif)
- 終止你想要刪除的實例(我看文檔說的是,終止實例其實就表示刪除了實例,終止實例會刪除掉服務器中的文件,可是中止實例不會)
![終止實例 終止實例](http://static.javashuo.com/static/loading.gif)
![終止實例會刪除掉服務器中的全部文件 終止實例會刪除掉服務器中的全部文件](http://static.javashuo.com/static/loading.gif)
![終止後的狀態 終止後的狀態](http://static.javashuo.com/static/loading.gif)
- 若是想完全刪除掉實例,還須要刪除掉 「卷」(不手動刪除的話,亞馬遜雲也會過一段時間自動刪除)
![選擇卷組 選擇卷組](http://static.javashuo.com/static/loading.gif)
![實例列表也會過一段時間自動刪除 實例列表也會過一段時間自動刪除](http://static.javashuo.com/static/loading.gif)
![直接在實例控制檯上面啓動一個新的實例 直接在實例控制檯上面啓動一個新的實例](http://static.javashuo.com/static/loading.gif)
![按照這些步驟一步一步的來,選擇你本身的自定義配置就能夠了 按照這些步驟一步一步的來,選擇你本身的自定義配置就能夠了](http://static.javashuo.com/static/loading.gif)
- 選擇硬盤空間大小(按需選擇就好,若是超過了套餐外的硬盤空間會收費,建議仍是先檢查本身的套餐最大硬盤空間)
![設置硬盤空間大小 設置硬盤空間大小](http://static.javashuo.com/static/loading.gif)
- 最最最重要的步驟就是,必定要選擇密鑰對或者直接在這裏生成密鑰對,而且必定要下載密鑰對,由於密鑰對只容許下載一次,錯過了,等於你這個實例就沒法登陸了。亞馬遜雲默認關閉了帳號密碼鏈接 ssh 服務,初次鏈接只容許密鑰對。
![選擇已生成的密鑰對或者直接在這裏生成 選擇已生成的密鑰對或者直接在這裏生成](http://static.javashuo.com/static/loading.gif)
![我沒有提早生成密鑰對,所以我在這裏直接生成一個密鑰對 我沒有提早生成密鑰對,所以我在這裏直接生成一個密鑰對](http://static.javashuo.com/static/loading.gif)
![下載密鑰對 下載密鑰對](http://static.javashuo.com/static/loading.gif)
![打開實例 打開實例](http://static.javashuo.com/static/loading.gif)
![已經安裝好了服務器 已經安裝好了服務器](http://static.javashuo.com/static/loading.gif)
建議仍是先看一下文檔:
https://docs.aws.amazon.com/z...
- 根據你選擇的系統尋找到亞馬遜雲默認給你建立的帳戶名
![我選擇的是 redhat 系統,所以用戶名是 ec2-user 或 root 我選擇的是 redhat 系統,所以用戶名是 ec2-user 或 root](http://static.javashuo.com/static/loading.gif)
![配置用戶身份驗證 配置用戶身份驗證](http://static.javashuo.com/static/loading.gif)
![導入密鑰對 導入密鑰對](http://static.javashuo.com/static/loading.gif)
![選中密鑰對 選中密鑰對](http://static.javashuo.com/static/loading.gif)
![效果以下 效果以下](http://static.javashuo.com/static/loading.gif)
![複製共有 DNS 複製共有 DNS](http://static.javashuo.com/static/loading.gif)
![配置鏈接 配置鏈接](http://static.javashuo.com/static/loading.gif)
![鏈接成功 鏈接成功](http://static.javashuo.com/static/loading.gif)
亞馬遜雲默認關閉了 root 鏈接 ssh,接下來說解如何使用 root 用戶登陸 ssh
- 更改 root 用戶密碼
sudo passwd root
- 切換到 root 用戶
su -
或者
su root
![修改 root 用戶密碼 修改 root 用戶密碼](http://static.javashuo.com/static/loading.gif)
- 修改 sshd_config 配置文件
vim /etc/ssh/sshd_config
若是提示沒有 vim 編輯器,則能夠直接使用 vi 編輯器
vi /etc/ssh/sshd_config
![編輯 sshd 服務主配置文件 編輯 sshd 服務主配置文件](http://static.javashuo.com/static/loading.gif)
- 開啓密碼驗證
PasswordAuthentication yes
![查看是否容許密碼驗證 查看是否容許密碼驗證](http://static.javashuo.com/static/loading.gif)
- 設定是否容許root管理員直接登陸
PermitRootLogin yes
![查看是否容許 root 管理員直接登陸 查看是否容許 root 管理員直接登陸](http://static.javashuo.com/static/loading.gif)
- 重啓 sshd 服務
// 重啓 sshd 服務
systemctl restart sshd
// 將 sshd 服務加入到開機啓動項中
systemctl enable sshd
- 測試鏈接
![使用公網 ip 和 root 用戶鏈接 ssh 使用公網 ip 和 root 用戶鏈接 ssh](http://static.javashuo.com/static/loading.gif)
![使用 root 帳號密碼鏈接 ssh 使用 root 帳號密碼鏈接 ssh](http://static.javashuo.com/static/loading.gif)
![至此,使用 root 用戶鏈接成功 至此,使用 root 用戶鏈接成功](http://static.javashuo.com/static/loading.gif)