Linux学习 Unit 9
Unit9.openssh-server
1.openssh-server
?
功能:讓遠(yuǎn)程主機(jī)可以通過(guò)網(wǎng)絡(luò)訪問(wèn)sshd服務(wù),開(kāi)始一個(gè)安全shell
?
2.客戶端連接方式
ssh遠(yuǎn)程主機(jī)用戶@遠(yuǎn)程主機(jī)ip
[root@desktop0 ~]# ssh root@172.25.0.11
The authenticity of host '172.25.0.11 (172.25.0.11)' can't be established.
ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.
Are you sure you want to continue connecting (yes/no)? yes ? ? ??##連接陌生主機(jī)時(shí)需要建立認(rèn)證關(guān)系
Warning: Permanently added '172.25.0.11' (ECDSA) to the list of known hosts.
root@172.25.0.11's password: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??##遠(yuǎn)程用戶密碼
Last login: Mon Oct ?3 03:13:47 2016
[root@server0 ~] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ###登陸成功
?
ssh 遠(yuǎn)程主機(jī)用戶@遠(yuǎn)程主機(jī)ip -X ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ##調(diào)用遠(yuǎn)程主機(jī)圖形工具
ssh ????遠(yuǎn)程主機(jī)用戶@遠(yuǎn)程主機(jī)ipcommand ? ? ? ? ? ? ? ? ? ? ? ? ??##直接在遠(yuǎn)程主機(jī)運(yùn)行某條命令
·設(shè)置虛擬機(jī)
·連接遠(yuǎn)程主機(jī)
·在遠(yuǎn)程主機(jī)上建立文件
?
?
?
3.sshkey加密
1.生成公鑰私鑰
[root@server0 ~]# ssh-keygen ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??##生成公鑰私鑰工具
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):[enter] ? ?##加密字符保存文件(建議用默認(rèn))
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): [enter] ? ? ? ? ? ? ? ?##密鑰密碼,必須>4個(gè)字符
Enter same passphrase again: [enter] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ##確認(rèn)密碼
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
ab:3c:73:2e:c8:0b:75:c8:39:3a:46:a2:22:34:84:81 root@server0.example.com
The key's randomart p_w_picpath is:
+--[ RSA 2048]----+
|o ???????????????|
|E. ??????????????|
|.. ??????????????|
|. ?. o ??????????|
|.o. * . S ???????|
|oo.o o ??. ??????|
|+ =. . ?. ???????|
|o. oo.+.. ???????|
| ???..o*. ???????|
+-----------------+
[root@server0 ~]# ls /root/.ssh/
id_rsa ?id_rsa.pub
id_rsa ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??##私鑰,就是鑰匙
id_rsa.pub ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??##公鑰,就是鎖
?
2.添加key認(rèn)證方式
[root@server0 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub ?root@172.25.0.11
ssh-copy-id ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?##添加key認(rèn)證方式的工具
-i ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??##指定加密key文件
/root/.ssh/id_rsa.pub ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?##加密key
root ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??##加密用戶為root
172.25.0.11 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?##被加密主機(jī)ip
?
3.分發(fā)鑰匙給client主機(jī)
[root@server0 ~]# scp /root/.ssh/id_rsa root@172.25.0.10:/root/.ssh/
4.測(cè)試
[root@desktop0 ~]# ssh root@172.25.0.11 ? ? ? ? ? ? ? ??##通過(guò)id_rsa直接連接不需要輸入用戶密碼
Last login: Mon Oct ?3 03:58:10 2016 from 172.25.0.250
[root@server0 ~]#
?
4.提升openssh的安全級(jí)別
1.openssh-server配置文件
/etc/ssh/sshd_config
78 PasswordAuthentication yes|no ? ? ? ? ? ?##是否開(kāi)啟用戶密碼認(rèn)證,yes為支持no為關(guān)閉
48 PermitRootLogin yes|no ? ? ? ? ? ? ? ? ??##是否允許超級(jí)用戶登陸
49 AllowUsers student westos ? ? ? ? ? ? ? ?##用戶白名單,只有在名單中出現(xiàn)的用戶可以使用sshd建立shell
50 DenyUsers westos ? ? ? ? ? ? ? ? ? ? ? ??##用戶黑名單
轉(zhuǎn)載于:https://blog.51cto.com/12774035/1914976
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的Linux学习 Unit 9的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: [Leedcode][JAVA][第12
- 下一篇: selinux 的管理