I have a jenkins setup at office, where jenkins (windows) is connected to slave (windows) over ssh using OpenSSH public private key authentication. The issue I am facing right now is with the access to the map drives on the slave. I have looked over internet for several solutions but could not able to access already mapped drives or map new drives from jenkins onto slave. I tried net use \shared\folder /user:domainname\user /p:yes and powershell command New-SmbMapping -LocalPath -RemotePath -Persistent:[$true|$false] and New-PSDrive -Name -Root -PSProvider FileSystem -Scope [Global|Local] -Persist:[$true|$false]. All these work fine when I run locally on the slave, even though there are mounted I could not access from jenkins master through running my job, as my jenkins pipeline job and builds access these n/w shared drives. I tried all these commands and passed the user/passwords through withCredentials. Everytime I receive the same error message "A specified logon session does not exist. It may already have been terminated"
BTW the jenkins on slave is not running as a windows service, running the slave.jar through java -jar command when the agent is launched. Also, the domain user is same everywhere used. When launching the agent using user/password credentials over ssh instead on keys, everything works fine but we got use keys for authentication, which is creating the issue.
I also tried running the groovy script within the job, to execute the net use but everytime a new it goes for approval and had to wait for that, which is not ideal for us
Could not able to figure out solution for this, does anyone have a similar issue being resolved ?