This is my command that I'm trying to connect to my server from Powershell:
$mysftp = @"
$(sftp -P2222 non-root-user@myserver.icom
"SomeRandomPass"
lcd C:\Users\Saeed\Desktop\test
cd /etc/
get hostname
bye)
"@
$mysftp
There are two issues:
- It asks again for my password
- It only connects to sftp but doesn't do anything.
- When I run
$mysftp
, it only prints the values of this variable, but doesn't execute that.
- The user is not
root
, so I cannot changesshd_config
to use keys to connect.
How can I connect to sftp and do my commands with no password in Powershell?
My Powershell version is PSVersion 5.1.19041.3031
.