I have downloaded the SSH activity package on the marketplace, it seems to work well. I use an SSH Connect Scope (the connection to the host is OK) in which I use an SSH Run Command activity. I am trying to upload a local file named “output.html” that I have on my WIndows machine to a Linux machine using SSH, in the /var/www/html folder. I did it with WinSCP, now I would like to do it in my process.
I used the following command: scp output.html /var/www/html
It fails, saying output.html cannot be found. I understood this is because it is looking for this file on the remote Linux machine while it is here, locally on my Windows machine.
So how can I upload this file?
@eric.marciano did you used SSH Upload Activity to upload file?
No, and I think this is what I need.
Where is this activity? It is not in the package I use…
@eric.marciano true its not there
use run command with below command
scp C:\path\to\output.html username@remote_host:/var/www/html
replace username with linux machine username and remote_host with IP/Hostname.
hope this works!
I am not sure about this process but i tried to get the answer in that i got some below statements, try this
- Inside the SSH Connect Scope, add the SSH Run Command activity.
- Set the Command property to the SCP command to upload the file, for example:
plaintext
Copy
scp C:/Users/YourUserName/Documents/output.html username@remote_host:/var/www/html/
Make sure to replace C:/Users/YourUserName/Documents/output.html
with the actual path to the file on your local machine and username@remote_host:/var/www/html/
with the correct destination path on the remote server.
- Execute:
- When you run the process, the file should be transferred to
/var/www/html
on the remote Linux machine.
Additional Considerations:
- Backslashes to Forward Slashes: Make sure to use forward slashes (
/
) for the local file path (C:/Users/...
) instead of backslashes (\
) when passing the file path in thescp
command. - Permissions: Ensure that the user account you’re using for the SSH connection has permission to write to the
/var/www/html/
directory on the remote Linux machine. - Firewall/Security Settings: Verify that no firewall or security settings block SCP traffic on the server.
Unfortunately it doesn’t work. Here is the command I use:
“scp C:\temp\output.html /var/www/html”
I have an error saying “ssh: Could not resolve hostname c: Temporary failure in name resolution
scp: Connection closed”
I understand it is trying to find the source file on the Linux machine, which is the target.
It almost works.
I had an error saying the connection to host on port 22 was refused. This is because port #22972 is used here. I could fix this by adding -P 22972 in the command line.
So the command is:
scp -P 22972 C:/temp/output.html uipathtransferuser@SVL078UIPHTMR1.tux.intra:/var/www/html/output.html
Now I have the following error: “Host key verification failed.” This is because my SSH requires an SSH key that I provided in the SSH Connect Scope (and it worked). I was hoping it wouldn’t block the scp command that is inside the SSH Connect Scope, but I was wrong…
Note: I am sure I have the appropriate rights because I did this operation manually using the WinSCP software and everything went well.
Eric, I think you need SFTP (FTP over SSH), which is included in UiPath.FTP.Activities. That way you don’t need dependencies like scp (also a valid alternative)
SSH Connector activities are mainly for executing remote commands in Unix/Linux systems (and very helpful)
Hope it helps!
I thought that SFTP and SSH were 2 different protocols. I am not sure I can use SFTP with an SSH host, I don’t even know how I can provide the key file (FTP requires a password).
In the meantime, I tried using the pscp command in PowerShell but I struggle with the Invoke PowerShell activity. Let’s say I want to run the following command: pscp fileA fileB, how must I configure the Invoke PowerShell activity?
I set ‘pscp’ as the CommandText, then I don’t know how to set the 2 arguments for fileA and fileB. I wanted to set them in the Parameters collection, but I must give each argument a name, and no name is needed here. Not sure I am clear…
You can use FTP Activities for SFTP and authenticate with username and password
or certificate file
I think it is the best approach. But PowerShell may work as well
Hope it helps!
I finally made it with PowerShell, but I like SFTP better. Give me the time to look into this, I hope I will also make it work.