sshd=secure shell
能夠經過網絡在主機中開啓shell的服務shell
客戶端軟件vim
sshd安全
鏈接方式服務器
ssh username@ip #文本模式的鏈接 ssh -X username@ip #能夠在連接成功後開啓圖形
注意;網絡
第一次鏈接陌生主機時,要創建認證文件,因此會詢問是否創建 須要輸入yes,再次連接此臺主機時,由於已經生成 xxx.ssh/know_hosts文件 因此再也不須要輸入yes
遠程複製:ssh
scp file root@ip:dir #上傳|本地文件 相對路徑 遠程主機ip 絕對路徑 scp root@ip:file dir #下載
-->ssh-keygen #生成命令
--> #指定保存加密字符的文件
--> #設定密碼(使用空密碼)
--> #確認密碼
‘/root/.ssh/id_rsa’ #鑰匙
'/root/.ssh/id_rsa.pub' #鎖頭測試
[root@server Desktop]# ls /root/.ssh
id_rsa id_rsa.pub known_hosts
[root@server Desktop]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.25.254.222#當前主機
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@172.25.254.222's password: 加密
Number of key(s) added: 1spa
Now try logging into the machine, with: "ssh 'root@172.25.254.222'"
and check to make sure that only the key(s) you wanted were added.3d
[root@server Desktop]# ls /root/.ssh
authorized_keys id_rsa id_rsa.pub known_hosts
^
此文件出現表示免密登錄能夠實現
scp /root/.ssh/id_rsa root@172.25.254.122:/root/.ssh/
在客戶主機中(172.25.254.100)
ssh root@172.25.254.200 #鏈接時發現會直接登錄,不須要root密碼
lient Desktop]# ls /root/.ssh
id_rsa known_hosts
[root@client Desktop]# ssh root@172.25.254.222
Last failed login: Mon Jul 23 04:16:00 EDT 2018 from 172.25.254.222 on ssh:notty
There were 3 failed login attempts since the last successful login.
Last login: Mon Jul 23 03:35:00 2018 from 172.25.254.122
[root@client Desktop]#vim /etc/ssh/sshd-config
78 PasswordAuthentication yes|no #是否容許用戶經過登陸系統的密碼作ssh的認證
48 PermitRootLogin yes|no #是否容許root用戶經過sshd服務的認證
52 AllowUsers student sheen #設定用戶白名單,白名單出現默認不在名單的用戶不能使用
53 DenyUsers westos #設定用戶黑名單,黑名單出現默認不在名單的用戶能夠使用
systemctl restart sshd.service #重啓配置文件
vim /etc/motd #文件內容就是登錄後顯示的信息
1.w
查看正在使用當前系統的用戶
-f #顯示來源
-i #顯示ip
/var/run/utmp
2.last #查看使用過並退出的用戶信息
/var/log/wtmp
3.lastb #試圖登錄但沒成功的用戶
var/log/btmp
注:用真實主機鏈接虛擬機,須要虛擬機開機