Login failed for user 'NT Service\SSISScaleOutMaster140' In times of creating replication by using below query I getting from log

Login failed for user 'NT Service\SSISScaleOutMaster140'

DECLARE @distributor AS sysname;
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
DECLARE @directory AS nvarchar(500);
DECLARE @publicationDB AS sysname;
-- Specify the Distributor name.
SET @distributor = N'ServerName'
-- Specify the distribution database.
SET @distributionDB = N'distribution';
-- Specify the Publisher name.
SET @publisher = N'ServerName;
-- Specify the replication working directory.
SET @directory = N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\repldata'
-- Specify the publication database.
SET @publicationDB = N'databasename'; 

-- Install the server MYDISTPUB as a Distributor using the defaults,
-- including autogenerating the distributor password.
USE master
EXEC sp_adddistributor @distributor = @distributor;

-- Create a new distribution database using the defaults, including
-- using Windows Authentication.
USE master
EXEC sp_adddistributiondb @database = @distributionDB, 
    @security_mode = 1;
GO

-- Create a Publisher and enable AdventureWorks2012 for replication.
-- Add MYDISTPUB as a publisher with MYDISTPUB as a local distributor
-- and use Windows Authentication.
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
-- Specify the distribution database.
SET @distributionDB = N'distribution';
-- Specify the Publisher name.
SET @publisher = N'ServerName;

USE [distribution]
EXEC sp_adddistpublisher @publisher=@publisher, 
    @distribution_db=@distributionDB, 
    @security_mode = 1;
GO
Not sure it this is exactly what you need for replication but it is worth a quick try.

SQL Server uses the server SID as part of the password encryption/generation. Often just creating the same user name and password on 2 servers that are in an Availability Group or Mirrored or Replicated, maybe for Linked servers as well. The general term for these cases is 'Orphaned Users'. You will see it often in your career.

So just using the same login name and password will give an error. Usually when something fails over at 3AM because it wasn't tested...

There are two ways to do this. The 'old school' way is to go to this link ( https://support.microsoft.com/en-us/help/918992/how-to-transfer-logins-and-passwords-between-instances-of-sql-server ) and run the included script on the server that works, meaning you can login to that server. The script will create two stored procedures in Master. You execute the sp_help_revlogin SP on the working server, it will generate SQL code that you can copy and paste into the non-working server.

From your explanation I suspect you will get an error about the login already existing, go ahead and drop the user on the non-working server. It will get created from the generated script.

The more 'modern' way is to use PowerShell, specifically the Copy-SqlLogin and Export-SqlLogin found at https://dbatools.io/

If you are comfortable using PowerShell, these should work well and are pretty well documented on the website.

Hopefully this will help or at least point to a better answer.

Norman