日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

远程访问与控制

發(fā)布時間:2024/2/28 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 远程访问与控制 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

  • 遠程訪問與控制
      • ssh遠程管理
      • 配置Open SSH服務(wù)端
        • ssh協(xié)議
      • openshh服務(wù)了解
      • 登錄驗證方式
      • 使用SSH客戶端程序
      • SSH客戶端程序命令
      • Xshell
      • 密鑰對驗證的SSH體系
      • 創(chuàng)建密鑰對圖解
    • TCP Wrappers控制
        • 保護原理

遠程訪問與控制

ssh遠程管理

大多數(shù)企業(yè)服務(wù)器是通過遠程登錄的方式來進行管理的

配置Open SSH服務(wù)端

ssh協(xié)議

為客戶機提供安全的shell環(huán)境,用于遠程管理,默認端口:TCP 22

openshh服務(wù)了解

服務(wù)名稱:sshd服務(wù)端主程序:/usr/sbin/sshd服務(wù)端配置文件:/etc/ssh/sshd_configssh_config:針對客戶端sshd_config:針對服務(wù)端 訪問形式端口號
SSH:密文訪問默認端口TCP:22,一般廣域網(wǎng)
Telnet:明文形式的訪問TCP 23,一般局域網(wǎng)
遠程桌面3389,圖形化界面

了解SSH服務(wù)

[root@localhost ~]# vi /etc/ssh/sshd_config #Port 22 端口號 #AddressFamily any #ListenAddress 0.0.0.0 監(jiān)聽地址 #ListenAddress ::

如果不想讓別人用root用戶進行遠程登錄呢?

## 修改ssh配置文件 [root@test01 ~]# vi /etc/ssh/sshd_config37 #LoginGraceTime 2m ## 會話時間,設(shè)置指定時間內(nèi)沒有成功登錄,將會斷開連接,若無單位則默認時間為秒 38 #PermitRootLogin yes ## 是否允許root登錄,默認為允許 39 #StrictModes yes ## 設(shè)置ssh在接收登錄請求之前是否檢查家目錄及rhosts文件權(quán)限和所有權(quán) 40 #MaxAuthTries 6 ## 密碼最大驗證次數(shù) 41 #MaxSessions 10 ## 最大會話連接數(shù)量## 將第38行的注釋取消,將yes改為no即可,重啟服務(wù)

但是這樣做也會有很嚴(yán)重的漏洞存在,開啟PAM認證模塊

[root@test01 ~]# vi /etc/pam.d/su 7 auth substack system-auth ## 將這一行的注釋符號去掉即可開啟PAM驗證功能

將tom用戶添加到wheel組

[root@test01 ~]# usermod -a -G wheel tom [root@test01 ~]# id tom uid=1000(tom) gid=1000(tom) 組=1000(tom),10(wheel) [root@test01 ~]# id tom1 ## 用戶tom1不屬于wheel組 uid=1001(tom1) gid=1001(tom1) 組=1001(tom1)

openSSH用戶登錄控制

shhd服務(wù)默認是允許root用戶登錄,在使用internet是不安全,普遍做法是:禁止root用戶,空密碼用戶,登錄時間,重試次數(shù)

AllowUsers(白名單,僅允許,只有這些可以登錄)

DenyUsers(黑名單,僅拒絕,只有這些不行)

AllowUsers不可與DenyUsers同時使用

[root@localhost ~]# vim /etc/ssh/sshd_config #LoginGraceTime 2m 會話時間,設(shè)置指定時間內(nèi)沒有成功登錄,將會斷開連接 #PermitRootLogin yes 是否允許root登錄,默認為允許 #StrictModes yes 是否允許root登錄,默認為允許 #MaxAuthTries 6 密碼最大驗證次數(shù) #MaxSessions 10 最大會話連接數(shù)量

登錄驗證方式

密碼驗證:核對用戶名,密碼是否匹配

密鑰對驗證:核對客戶的私鑰,服務(wù)端公鑰是否匹配

公鑰:服務(wù)器使用

私鑰:客戶保留

非對稱秘鑰:RSA

對稱秘鑰:3DES,AES

[root@localhost ~]# vi /etc/ssh/sshd_config #PasswordAuthentication yes 是否使用密碼 #PermitEmptyPasswords no 禁止空密碼 PasswordAuthentication yes 是否需要密碼驗證

增加密碼嘗試次數(shù)

[root@test02 ~]# ssh -o NumberOfPasswordPrompts=8 tom@192.168.50.131

使用SSH客戶端程序

SSH客戶端程序命令

ssh命令–遠程安全登錄

[root@wanwu ~]# ssh root@192.168.136.190 root@192.168.136.190's password: 驗證root密碼 Permission denied, please try again. root@192.168.136.190's password: Last failed login: Thu Jul 9 17:24:46 CST 2020 from 192.168.136.100 on ssh:notty There was 1 failed login attempt since the last successful login. Last login: Thu Jul 9 17:24:25 2020 from 192.168.136.2 [root@lisi ~]#

scp命令——遠程安全復(fù)制

基本命令{文件和目錄復(fù)制} [root@wanwu opt]# scp -r text/ root@192.168.136.190:/home/ 將本機目錄text/以root權(quán)限復(fù)制到192.168.136.190中的home下 [root@wanwu opt]# scp ssh_shbi123 root@192.168.136.190:/home/ 將本機文本ssh_shbi123/以root權(quán)限復(fù)制到192.168.136.190中的home下

sftp命令–安全FTP上下載

命令基本格式 sftp user@host get:下載 put:上傳 [root@wanwu opt]# sftp root@192.168.136.190 在192.168.136.190下面的home目錄下 root@192.168.136.190's password: Connected to 192.168.136.190. sftp> ls

Xshell

強大的安全終端模擬軟件

密鑰對驗證的SSH體系

創(chuàng)建密鑰對圖解

創(chuàng)建密鑰對

在客戶機中創(chuàng)建密鑰對 ssh-keygen命令 可用的加密算法:RSA或DSA 或ecdsa 橢圓曲線加密 [root@test02]# ssh-keygen -t ecdsa Enter file in which to save the key (/root/.ssh/id_ecdsa): # 指定出秘鑰存放路徑 Enter passphrase (empty for no passphrase): ## 輸入秘鑰對密碼 Enter same passphrase again: ## 再次確認密碼 Your identification has been saved in /root/.ssh/id_ecdsa. Your public key has been saved in /root/.ssh/id_ecdsa.pub. The key fingerprint is: SHA256:BiFecEuu1UyGxVx6xWEWDYEiFb3hGXX9SnnhpPiAzDE root@wanwu The key's randomart image is: +---[ECDSA 256]---+ | o.=**+.+X*.. | | . *oB+E=+...o.| | . =.*o==. +.o| | o . =+o .o.o| | . S o. o | | . .. | | | | | | | +----[SHA256]-----+

查看密鑰

[root@test02]# ls -a 家目錄下面的.ssh . .. anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .cshrc .ssh .tcshrc .viminfo [root@test02]# cd .ssh/ [root@test02]# ls id_ecdsa id_ecdsa.pub known_hosts 公鑰和私鑰生成

上傳公鑰文件 id_rsa.pub,秘鑰對已經(jīng)生成,公鑰上傳到服務(wù)端

[root@test02 ]# ssh-copy-id -i id_ecdsa.pub lisi@192.168.136.190 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_ecdsa.pub" /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 tom@192.168.50.131's password: ## 輸入tom用戶的密碼Number of key(s) added: 1 ## 秘鑰添加成功Now try logging into the machine, with: "ssh 'tom@192.168.50.131'" and check to make sure that only the key(s) you wanted were added

進入make查看

[make@test01 .ssh]$ ls authorized_keys known_hosts ## 秘鑰已經(jīng)上傳## 查看一下公鑰內(nèi)容: [make@test01 .ssh]$ cat authorized_keys ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBB6eSY2pLpU2MM2xT8hGpM5ogSVOLCbgtHxNnzAIg+lsxG95kkSV8LN++6q9IhRpTxyXdt86bs5hznP+JfWxpgk= root@test02## 可以看出是test02的make用戶上傳的 [root@test02 .ssh]# ssh tom@192.168.50.131 Enter passphrase for key '/root/.ssh/id_ecdsa': 輸入密鑰對密碼 Last login: Sat Jul 11 21:31:11 2020 [tom@test01 ~]$ 成功

免密登陸

[root@test02 .ssh]# ssh-agent bash ## 代理bash終端 [root@test02 .ssh]# ssh-add ## 添加免密登陸的密碼 Enter passphrase for /root/.ssh/id_ecdsa: ## 輸入創(chuàng)建秘鑰對時的密碼 Identity added: /root/.ssh/id_ecdsa (/root/.ssh/id_ecdsa)

TCP Wrappers控制

保護原理

查看文件是否存在

[root@localhost etc]# ls ./ | grep *.allow hosts.allow [root@localhost etc]# vi hosts.allow 白名單 sshd:192.168.136.218 僅允192.168.136.218IP訪問ss [root@localhost etc]# vi hosts.deny 黑名單 shhd:ALL 禁止其他所有地址訪問 白名單優(yōu)先

保護原理

查看文件是否存在

[root@localhost etc]# ls ./ | grep *.allow hosts.allow [root@localhost etc]# vi hosts.allow 白名單 sshd:192.168.136.218 僅允192.168.136.218IP訪問ss [root@localhost etc]# vi hosts.deny 黑名單 shhd:ALL 禁止其他所有地址訪問 白名單優(yōu)先

總結(jié)

以上是生活随笔為你收集整理的远程访问与控制的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。