Linux的SSH(Secure Shell Protocol)服務

來源:互聯網
上載者:User

Linux的SSH(Secure Shell Protocol)服務

在資料轉送前,SSH會對需要傳輸的資料進行加密,保證會話安全與會話中傳輸資料的安全,SSH用戶端還包含一個遠程拷貝scp。

1、SSH的結構

SSH服務由服務端軟體(openssh)和用戶端(SSH、SecureCRT、Xshell)組成,SSH預設使用22連接埠,SSH服務端是一個守護進程,在後台時刻監聽用戶端的請求,sshd就是SSH服務端的進程名

補充:(守護進程)

守護進程是一個在後台運行並且不受任何終端控制的進程。Unix作業系統有很多典型的守護進程(其數目根據需要或20—50不等),它們在後台運行,執行不同的管理工作。

使用者使守護進程獨立於所有終端是因為,在守護進程從一個終端啟動的情況下,這同一個終端可能被其他的使用者使用。例如,使用者從一個終端啟動守護進程後退出,然後另外一個人也登入到這個終端。使用者不希望後者在使用該終端的過程中,接收到守護進程的任何錯誤資訊。同樣,由終端鍵人的任何訊號(例如中斷訊號)也不應該影響先前在該終端啟動的任何守護進程的運行。雖然讓伺服器後台運行很容易(只要shell命令列以&結尾即可),但使用者還應該做些工作,讓程式本身能夠自動進入後台,且不依賴於任何終端。

守護進程沒有控制終端,因此當某些情況發生時,不管是一般的報告性資訊,還是需由管理員處理的緊急資訊,都需要以某種方式輸出。Syslog 函數就是輸出這些資訊的標準方法,它把資訊發送給 syslogd 守護進程。

2、SSH認證類型

(1)基於口令的安全驗證,也就是通常所說的帳號、密碼、連接埠、IP登入

(2)基於密鑰的安全驗證

  事先建立一對金鑰組,然後將公用的密鑰放在服務端,把私人的密鑰放在SSH的用戶端,最終通過這種密鑰驗證方式進行加密傳輸資料。

3、SCP

NAME
    scp - secure copy (remote file copy program)  #安全拷貝

SYNOPSIS
    scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
        [-l limit] [-o ssh_option] [-P port] [-S program]
        [[user@]host1:]file1 ... [[user@]host2:]file2

DESCRIPTION
    scp copies files between hosts on a network.(scp是在網路上通過host之間拷貝檔案)  It uses ssh(1) for
    data transfer, and uses the same authentication and provides the
    same security as ssh(1).  Unlike rcp(1), scp will ask for pass-
    words or passphrases if they are needed for authentication.

    File names may contain a user and host specification to indicate
    that the file is to be copied to/from that host.  Local file
   names can be made explicit using absolute or relative pathnames
    to avoid scp treating file names containing ‘:’ as host speci-
    fiers.  Copies between two remote hosts are also permitted.

    When copying a source file to a target file which already exists,
    scp will replace the contents of the target file (keeping the
    inode).

    If the target file does not yet exist, an empty file with the
    target file name is created, then filled with the source file
    contents.  No attempt is made at "near-atomic" transfer using
    temporary files.

-P  連接埠

-p  保持屬性

-r  拷貝目錄

4、FTP功能服務sftp

上傳:

[root@localhost tmp]# sftp -oport=22 root@192.168.181.129
Connecting to 192.168.181.129...
root@192.168.181.129's password:
sftp> put /tmp/666 /tmp
stat /tmp/666: No such file or directory
sftp> put /tmp/123.txt /tmp
Uploading /tmp/123.txt to /tmp/123.txt
/tmp/123.txt                                100%    0    0.0KB/s  00:00

查看上傳成功!

下載:

sftp> get /tmp/666 /tmp
Fetching /tmp/666 to /tmp/666
sftp> get /tmp/666 /opt
Fetching /tmp/666 to /opt/666

檢查下載到本地成功!

本文永久更新連結地址:https://www.bkjia.com/Linux/2018-02/150990.htm

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.