All Products
Search
Document Center

Bastionhost:Best practices for auditing SCP-based operations

Last Updated:May 28, 2024

Bastionhost cannot audit secure copy (SCP) commands. To audit SCP-based operations by using Bastionhost, you can configure ProxyJump on your computer before you run SCP commands to transfer files.

Background information

ProxyJump is supported by OpenSSH 7.3 and later. When you run SCP commands to upload or download files from an SSH client on a computer configured with ProxyJump, the SSH client establishes a secure connection to your bastion host first. Then, the SSH client communicates with the host on which you want to upload or download files by using the bastion host. This way, you can use your bastion host to audit SCP-based operations.

Prerequisites

Configure ProxyJump

  1. Log on to the on-premises Linux computer.

  2. Run the following command to create the config file in the .ssh directory and configure the parameters.

    vim ~/.ssh/config

    The following sample code provides an example on how to configure the parameters:

    #-------Configuration of the bastion host---------#
    
    # The alias of the bastion host.
    Host bastion
        # The O&M address of the bastion host.
        HostName ****-public.bastionhost.aliyuncs.com 
        # The port number of the bastion host. The default port is 60022.
        Port 60022 
        # The user of the bastion host.
        User bastion-user
    # -------Configuration of the host managed by the bastion host---------#
    
    # The alias of the host.
    Host target-host-A 
        # The IP address of the host.
        HostName 192.168.XX.XX 
        # The username of the host.
        User tagert-user
        # Configure ProxyJump. When you run SCP commands, the SSH client connects to the bastion host and then connects to the host target-host-A by using the bastion host.
        ProxyJump bastion 
    # --------Support for multiple hosts--------#
    #Host target-host-B
    #    HostName 192.168.XX.XX 
    #    User tagert-user
    #    ProxyJump bastion 
  3. Run SCP commands to upload files to the host or download files to your computer. Examples:

    • Upload a file to the host:

      The following sample code provides an example on how to upload the file-name.txt file to the home directory on the host target-host-A.

      scp /file-name.txt target-host-A:/home/
    • Download a file to your computer:

      The following sample code provides an example on how to download the file-name.txt file from the host target-host-A to the home directory on your computer.

      scp target-host-A:/file-name.txt /home/

View audit logs in the bastion host

Log on to the bastion host to view the audit logs of SCP-based operations. For more information, see Search for sessions and view session details.

image