Am 17.08.2016 um 02:26 schrieb Kiran:
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/
Which OpenSSH? Cygwin's? Does it generally work?
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.
Should be 0700. And, did you also change its ownership and that of
all files inside to the Jenkins user?
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
jen...@x.x.x.x
echo "something" > foo.txt
exit
Don't know why you think you need to use -t, though. However, you
NEED to provide the private key: -i /path/to/keyfile. BTW: This will
not execute any command on the remote host, since you've spilt it
into separate lines. So the correct command would be:
ssh -i /home/jenkins/.ssh/great.key
jen...@x.x.x.x 'echo
"something" >foo.txt'
I get this in the console output:
...
Permission denied, please try again.
That might come from the wrong .ssh directory permissions, see
above.
How do I get Jenkins running on Linux to
communicate with Windows servers?
Fix the .ssh directory (and contens) permissions. Make sure the
connection generally works (from outside Jenkins). You also need to
log in once manually (as the Jenkins user on Linux), to have the
host key of the Windows host added to its known_hosts file.
I would rather not install Cygwin on the Linux
servers.
Well, you can't (it's a Windows thing, hence the name CygWIN).
HTH...
Dirk