scp from Linux to Windows server 2008

Hello experts,

I'm having problems moving files from my Linux system (Ubuntu) to my Windows server 2008 using scp. I've established a SSH connection (using KTS on the server) and that works fine, although it's pretty slow even when I'm using it through my LAN.
After getting the SSH connection to work I tried scp (scp someFile serverUser@ipAddress:'C:\') but that does not work. It asks me for the serverUser password and then returns control but nothing happens (at least no someFile on the Windows server).
Am I doing something stupidly wrong ???

I tried using FreeSSH and openSSH on the Windows machine but neither of them worked in case that matters.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

did try to search for the file on the windows system? it could be that the file is created under different dir.

after asking for password does it wait or return prompt immediately ?
maybe  the server and the ubuntu are using different authentication methods .
on the win server you have to configure allowed authentication  methods.
did you try to exchange keys and login without password ?
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

I would try getting rid of the C:\  I've seen ssh/scp servers on Windows getting "confused" occasionally between unix path notations and windows path notations.  For example, using cygwin, to access the c drive, you would use /cygdrive/c, instead of C:\  I've no idea what the equivalent with KTS is though.

Try the following: "scp someFile serverUser@ipAddress:"  

This should (in theroy) save it in your "home dir"  When you ssh to the box, run a pwd before doing anything else to see which directory this is, for example it could be c:\documents and settings\user_name, or it could be my documents, or even a KTS directory.

If this isn't working, try the scp command with a -vvv, eg: "scp -vvv someFile serverUser@ipAddress:", which will show you what its actually doing (if anything)
MannsiAuthor Commented:

I've tried searching for the file on the Windows system, it's not there.

If SSH works, doesn't that mean that the authentication method works ?

I tried doing the "scp someFile serverUser@ipAddress:"  but that does not seem to work either.

Finally I did the "scp -vvv someFile serverUser@ipAddress:"  and it gave me a bunch of information
that's a couple of pages long that I attached below

mannsi@mannsi-laptop:~$ scp -vvv mannsi.eps Administrator@
Executing: program /usr/bin/ssh host, user Administrator, command scp -v -t .
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to [] port 22.
debug1: Connection established.
debug1: identity file /home/mannsi/.ssh/identity type -1
debug1: identity file /home/mannsi/.ssh/id_rsa type -1
debug1: identity file /home/mannsi/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version cryptlib
debug1: no match: cryptlib
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,,hmac-ripemd160,,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,,hmac-ripemd160,,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,,zlib
debug2: kex_parse_kexinit: none,,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa
debug2: kex_parse_kexinit: 3des-cbc,blowfish-cbc,cast128-cbc,idea-cbc
debug2: kex_parse_kexinit: 3des-cbc,blowfish-cbc,cast128-cbc,idea-cbc
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: none
debug2: kex_parse_kexinit: none
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client 3des-cbc hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server 3des-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 199/384
debug2: bits set: 1006/2048
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /home/mannsi/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host '' is known and matches the RSA host key.
debug1: Found key in /home/mannsi/.ssh/known_hosts:1
debug2: bits set: 1016/2048
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/mannsi/.ssh/identity ((nil))
debug2: key: /home/mannsi/.ssh/id_rsa ((nil))
debug2: key: /home/mannsi/.ssh/id_dsa ((nil))
debug1: Authentications that can continue: password
debug3: start over, passed a different list password
debug3: preferred gssapi-keyex,gssapi-with-mic,gssapi,publickey,keyboard-interactive,password
debug3: authmethod_lookup password
debug3: remaining preferred: ,gssapi-with-mic,gssapi,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
Administrator@'s password: 
debug3: packet_send2: adding 56 (len 68 padlen 4 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
debug2: fd 4 setting O_NONBLOCK
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env GPG_AGENT_INFO
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env XDG_SESSION_COOKIE
debug3: Ignored env WINDOWID
debug3: Ignored env XTERM_SHELL
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env GNOME_KEYRING_SOCKET
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env USERNAME
debug3: Ignored env DESKTOP_SESSION
debug3: Ignored env PATH
debug3: Ignored env GDM_XSERVER_LOCATION
debug3: Ignored env PWD
debug3: Ignored env JAVA_HOME
debug3: Ignored env GNOME_KEYRING_PID
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env GDM_LANG
debug3: Ignored env GDMSESSION
debug3: Ignored env HISTCONTROL
debug3: Ignored env XTERM_LOCALE
debug3: Ignored env XTERM_VERSION
debug3: Ignored env HOME
debug3: Ignored env SHLVL
debug3: Ignored env LOGNAME
debug3: Ignored env CLASSPATH
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env LESSOPEN
debug3: Ignored env WINDOWPATH
debug3: Ignored env DISPLAY
debug3: Ignored env LESSCLOSE
debug3: Ignored env XAUTHORITY
debug3: Ignored env _
debug1: Sending command: scp -v -t .
debug2: channel 0: request exec confirm 0
debug2: fd 3 setting TCP_NODELAY
debug2: callback done
debug2: channel 0: open confirm rwindow 2147483647 rmax 16384
debug2: channel 0: read<=0 rfd 4 len 0
debug2: channel 0: read failed
debug2: channel 0: close_read
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug2: channel 0: input drain -> closed
mannsi@mannsi-laptop:~$ debug2: channel 0: write failed
debug2: channel 0: close_write
debug2: channel 0: output open -> closed
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cfd -1)
debug3: channel 0: close_fds r -1 w -1 e 8 c -1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to closed by remote host.
debug1: Transferred: stdin 0, stdout 0, stderr 51 bytes in 304.2 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.2
debug1: Exit status -1

Open in new window

Kerem ERSOYPresidentCommented:

First of all it seems that at this point the server is rejecting your keys:
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/mannsi/.ssh/identity ((nil))
debug2: key: /home/mannsi/.ssh/id_rsa ((nil))
debug2: key: /home/mannsi/.ssh/id_dsa ((nil))
debug1: Authentications that can continue: password
debug3: start over, passed a different list password

and reverts back to password authentication. It might mean that your directory permissions is wrong and ssh won't authenticate you when your directory permissions are bad.

Try these commands:

cd     (to locate you on your home)
chmod 700 .ssh
cd .ssh
chmod 600 *
if you have not already done so add your and idrsa_pub to your authorizde keys such as:
cat >> authorized_keys
cat >> authorized_keys

Let me know what happens.


MannsiAuthor Commented:
Should I try these commands one by one and try to SCP between or ... ?
Kerem ERSOYPresidentCommented:
Nope you should do them at once and then try ssh after you finish. I'll suggest you to check directory permissions at windows level too. Finally as another expert suggested dont use "C:\" in your path as it would confuse the scp at linux end.
MannsiAuthor Commented:
I've dropped the C\: part.

I did the first few commands no problem but I can't locate the files cat and
cat so that dind't work.

Also, should I check the file permission where the SSH connection starts at default. Did you mean to say that I should try scp and not ssh in your last comment, as I can ssh connect to the Windows machine ?
Kerem ERSOYPresidentCommented:
ok will you go to your linux system and post the output of:

cd .ssh
ls -al
MannsiAuthor Commented:

total 12
drwx------  2 mannsi mannsi 4096 2009-05-26 13:18 .
drwxr-xr-x 92 mannsi mannsi 4096 2009-05-25 16:41 ..
-rw-r--r--  1 mannsi mannsi    0 2009-05-26 13:18 authorized_keys
-rw-------  1 mannsi mannsi  548 2009-05-25 16:13 known_hosts

Open in new window

Kerem ERSOYPresidentCommented:
ok to be able to logon you'l need both public and private keys. So what I'll suggest is to recreate them since you don't have your private key now. So lets delete these files and restart:

# cd
# cd .ssh
# rm -rf *
# ssh-keygen -t rsa

It will output:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kerem/.ssh/id_rsa):    (press enter to accept the default)

Then it will ask for password. Enter the password twice.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

When you hit ennter you'll get something similar to this:

Your identification has been saved in /home/kerem/.ssh/id_rsa.
Your public key has been saved in /home/kerem/.ssh/
The key fingerprint is:
e3:64:d1:65:59:d2:46:11:17:89:4e:a9:5b:30:39:d3 kerem@moose.sibernet.sec

now you have your new certificate. Copy your public key to authorized_keys

# cat > authorized.keys
# chmod 600 *
# ls -al

You should have something like this:
total 40
drwx------ 2 kerem kerem 4096 May 26 17:14 .
drwx------ 7 kerem kerem 4096 May 24 20:58 ..
-rw------- 1 kerem kerem  406 May 26 17:14 authorized_keys
-rw------- 1 kerem kerem 1675 May 26 17:11 id_rsa
-rw------- 1 kerem kerem  406 May 26 17:11

Congratulations. Now you should be able to logon with your key klets give it a try:

# ssh -i id_dsa kerem@localhost
Warning: Identity file id_dsa not accessible: No such file or directory.
The authenticity of host 'localhost (' can't be established.
RSA key fingerprint is b4:75:b4:7a:a9:1a:06:aa:67:29:8a:41:0c:6e:af:c4.
Are you sure you want to continue connecting (yes/no)?

Type yes <enter>

It will ask pasword and once you've entered the password you'll get something like this:
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Last login: Mon May 25 16:06:39 2009 from localhost.localdomain

Now get your public key to your Windows Server. You should be using it to logon your server for scp.

Kerem ERSOYPresidentCommented:
Sorry when I told public key I meant your private key: id_rsa if you want you can delete the id_rsa from your server once you've transfer it to the PC. Keep this id_dsa file becasue you'll need it when you want to logon your system without password.

Kerem ERSOYPresidentCommented:
Opps this should read:
# ssh -i id_rsa kerem@localhost

not id_dsa sotrry for typo.
MannsiAuthor Commented:
Ok, everything worked the way you said it would but I don't know how to do this "Now get your public key to your Windows Server" ?

Do I need to use ssh with the -i id_rsa in the future or was that a one time thing ?
Monis MontherSystem ArchitectCommented:

why not simply do it the other way

from Windows

pscp -r user@ip.addr:/path/to/files .

note there is a dot at the end which means the current directory from where you issue the pscp command,in this case you will not need any ssh server or anything on your windows machine just the pscp.exe which you can download for free

Kerem ERSOYPresidentCommented:
In fact when I've read the original posting I'd thought the asker was running a ssh server over his Windows. But then Cheching the OpenSSH page I've seen that there are not so much open products around to provide windows with SSH server functionality. And when I saw the user is actually logged on to his ubuntu to do the checking I've got the impression that the user has only one SSH server in ubuntu and he's using SCP to copy files over the windows.

Will the asker clarify this ?
MannsiAuthor Commented:
I've got an KpyM Telnet SSH server on the Windows machine. I hope this answers your question KeremE. All I want to do is to send files from my Ubuntu machine to my Windows Server machine.

small_student: are you talking about SSH-ing into the Windows machine and issuing that command from it ?
I'm not familiar with the program to you refer to.

Please ask if I haven't answered your questions.
MannsiAuthor Commented:
If you guys know of another way of getting my files from the Linux machine to the Windows 2008 server, I'm all for it. I just felt that scp was the cleanest way, but since it's proving to be a problem I'm open to new ideas.
Kerem ERSOYPresidentCommented:
In fact you don't need a SSH server on your windows host to get your files to Windows. There's a small windows utility called WinSCP that you can find here:
It is an open source free program. Once you've downloaded it you would add your Linux hosts address. Then when you click logon it will connect to your Linux machine. It divides your screen into two parts the left pane is your windows system and tje right pane is the linu system. Now you can drag and drop your files in linux to pc.

Is it Ok for you just logon and grab your files manually? Orwhat you're looking for is to automate the process?


MannsiAuthor Commented:
I assume that WinSCP requires me to be working on the Windows machine. My problem is that I will only be working on the Linux machine.

Grabbing the files manually is enough.
Kerem ERSOYPresidentCommented:

Though you can use KpyM Telnet SSH server for a telnet or SSH connection to your Windows server KpyM Server does not support SCP. All you could use is sftp.

Another limitation of KpyM Server is it can only authenticate local users not Domain Users. So If you are planning to send files to a domain controller it is not possible since there are no local users  over the domain controllers.

Since these are being said you can do a sftp coonection to your servser using this command:

sftp -oUser=administrator <IP_or_NAme_of_yourServer>

You need to authenticate using password. Then you will have an ftp like interface so that you can transfer your files. But the functionality is limited.

Why don't you use FTP  to transfer files instead? FTP is faster and more flexible when it comes to configuration.
MannsiAuthor Commented:
Do I need to have a FTP server on the Windows machine or how does that work ?
Kerem ERSOYPresidentCommented:
In fact Windows Servers come witha FTP service but it is primitive and hard to use. I'll suggest you u use FileZilla. You can find it here:
It is free open source and easy to use.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.