I have Jenkins 1.6 running on CentOS 7.2. I have Windows 2012 servers that I want to receive builds from the Jenkins server. These Windows servers are not on a domain. They have OpenSSH installed on them. On the Jenkins server, I manually created this path (from the Linux console): /home/jenkins/.ssh/

I gave the .ssh folder fully open privileges. I then ran a Jenkins job to happen solely on the Linux server itself. It was an Execute Shell job with these commands:

cd /tmp/
ssh-keygen -t rsa -N "" -f great.key
mv great.key.pub /home/jenkins/.ssh/
mv great.key /home/jenkins/.ssh

The commands should generate an SSH key pair for the Jenkins user. I do not know how to log into the Linux server with the Jenkins user. So I came up with the above.

I then manually made the permissions of the .ssh directory to be 600. I copied the contents of the .pub file into the authorized_keys file on the Windows server, specifically the file in C:\Users\jenkins.ssh\

Both the authorized_keys file and .ssh folder on the Windows server have security permissions wherein only the administrators group has full control of the file and and folder respectively. Then I ran a Jenkins build that was an Execute Shell script. Here are the three lines:

ssh -t -t [email protected]
echo "something" > foo.txt

I get this in the console output:

... Permission denied, please try again. ... Build step 'Execute shell' marked build as failure ...

How do I get Jenkins running on Linux to communicate with Windows servers? I would rather not install Cygwin on the Windows servers. There are license issues. It takes time to do that, and I think it is unnecessary.

  • What do you want to do exactly? Do you want to deploy your built application on Windows? Or do you want to build your application on Windows?
    – aairey
    Aug 17, 2016 at 7:30
  • I want to transfer files to Windows and launch .ps1 files on the Windows server. I want Jenkins on Linux to schedule these actions.
    – Kiran
    Aug 20, 2016 at 20:37

1 Answer 1


To investigate what's happening use some basic commands both in exec section of plugin and in running script. As first you have to compare paths for deployed script and for working folder. In my case script deploing path is /home/jenkins/deploy and command exec path is /home/jenkins. Use dirs command for example. Also consider to use absolute paths and/or cd command.

Then you may notice that script written in Windows has CRLF line-ending while written in Linux has LF only. Here interpreter sees in nonnative script extra things and treats them:

  • Linux interpreter sees extra \r characters before each expected \n line-ending and treats them:

    • as extra parameters in every command. It may produce warning from command about unexpected argument.

      #                            |normal line-end
      echo "something" > foo.txt \r\n
      #      ^arg  pipe^ target^ ^argument of target?
    • as unknown command in empty lines

      #  |normal line-end
      #^unknown command
  • Windows interpreter sees extra \n characters (and don't see expected \r\n) and treats all of them and next commands as one arguments-list for a first command

        #                                 |>no line-end
        echo "something" > foo.txt \n exit
        #      ^arg  pipe^ target^ ^---^-arguments of target

I use Publish Over SSH plugin for Jenkins and inverted situation: build machine (source) runs Windows and deploy machine (target) runs Linux(Ubuntu).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .