Solved

SCP from Linux to Windows freeSSHD

Posted on 2011-02-28
28
8,734 Views
Last Modified: 2014-04-17
I have installed freeSSHD on Windows Server 2008, I would like to simply scp files to the server...
I have configured passwords, and ssh-keys.

i can
ssh -P 9000 root@WinServ (works perfectly WinServ replaced with IP address)

I have two issues when scp-ing files

One the files never get to the windows server

scp -v -P 9000 'root@WINSERV:' /tmp/test

Two Not 100% sure of the syntax for the Windows file server part of the command.




Looks like it should work?
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 9000.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type 2
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version WeOnlyDo 2.1.3
debug1: no match: WeOnlyDo 2.1.3
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'xxx.xxx.xxx.xxx' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:16
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Offering public key: /root/.ssh/id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: read PEM private key done: type DSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: scp -v -f .
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.0 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status -1
0
Comment
Question by:hdaz
  • 10
  • 7
  • 5
  • +2
28 Comments
 
LVL 1

Expert Comment

by:rzup
ID: 34998930
I've never used the windows server, but the syntax looks wrong in general
scp   somefiletocopy.txt   somename@someserver:/tmp/filedir/
0
 
LVL 6

Expert Comment

by:t-max
ID: 34999439
The problem is that you are not specifying what do you want to copy from Winserv.
Put a wildcard (like below) or a filename, and it will be copied to /tmp/test
scp -v -P 9000 'root@WINSERV:*' /tmp/test
If you want to copy some folder recursively, use "-r".

For the windows side, you can use programs like WinSCP to have an interactive session from where you can connect and copy files with simple drag & drop.

If you have any further questions, let us know. G' luck!
0
 
LVL 3

Expert Comment

by:Alberto Cortes
ID: 35003197
Your syntax should be:

scp -v -P 9000 <file_to_copy> root@WINSERV:/tmp/test

Where:
<file_to_copy> should include the complete path and file name.
0
 
LVL 1

Author Comment

by:hdaz
ID: 35005403
Thanks for the suggestions, I know the syntax is not the same as I would do for a linux machine but thats the only example I could find online...

doing
scp -v -P 9090 /home/sbsbody/matrix_11153 'root@192.168.0.210:*'

does the same for me

The /tmp/test is the file I am sending not the location on the windows server I am sending too I have tried d:\ as well as just a folder name, idealy I would like it to be D:\Backups

debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.0 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0

nothing is ever sent, but no error is returned
0
 
LVL 6

Expert Comment

by:t-max
ID: 35006158
The syntax is:
scp DIRSOURCE USER@HOST:DIRTARGET

So in your case, the last asterisk is wrong. Try without it:
scp -v -P 9090 /home/sbsbody/matrix_11153 root@192.168.0.210:
This should copy /home/sbsbody/matrix_11153 into the home directory defined for root in 192.168.0.210.

Remember to check WinSCP, as I'm sure it will cover most of your needs on the Windows' side.
Let us know how goes. Regards!
0
 
LVL 1

Author Comment

by:hdaz
ID: 35006435
t-max- thanks for the reply..

with
  scp -v -P 9090 /home/sbsbody/matrix_11153 root@192.168.0.210:

debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.0 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0

i.e. nothing sent... either there is a problem with scp and the keys even thought they say accepted or the syntax of the command or something wrong in freeSSHD setup.

WINSCP, i can certainly set up WINSCP to grab a file or folder not a problem at all, but I dont want the Windows box to have access to the Linux server, I want the Linux server to have access to the Windows Server. Hence the logic in trying to find this solution.

eventually it will all be done via crontab....
0
 
LVL 6

Expert Comment

by:t-max
ID: 35007425
Read this http://www.freesshd.com/index.php?ctt=forum&action=view&topic=1118883373
Perhaps the info there will help you solve it.
0
 
LVL 1

Author Comment

by:hdaz
ID: 35008127
Not 100% on which problem I am hitting... but it does look similar.

------------------
find the probem!

Change the SFTP server settings under the FreeSSHd GUI. Put away the $HOME in the 'Home Path'. A 'password stored as SHA1 hash' user do not have a $HOME.
Maybe someone of freeSSHd can fix this, because it takes you a long time, because the logging do not give a lot information.
--------------------
I tried putting in C:\Users\<USERNAME>\ not sure what is meant by the above...

still gives me the same results.. I am going to try this on a fresh-ish VM and see if I can get it to work.... I am sure I had it working at home but can not remember if it was scp or just ssh...

Thanks for your help...
0
 
LVL 12

Expert Comment

by:mccracky
ID: 35008203
First, can you actually ssh into the server?  If you can't ssh, you won't be able to scp.
0
 
LVL 6

Expert Comment

by:t-max
ID: 35008462
0
 
LVL 1

Author Comment

by:hdaz
ID: 35009793
mccracky
        yes 100% I can ssh into the server
   ssh -P 9000 root@WinServ (works perfectly WinServ replaced with IP address)

t-max
  I did see that guide while looking for solutions pretty much identical from the install and configure side, apart from trying different options along the way..  The only other part might be win2008 and or permissions within windows.

The install looks like it was done on XP because of the word document.
0
 
LVL 6

Expert Comment

by:t-max
ID: 35009902
When you ssh into Winserv, in which directory are you placed?
Do you have write permissions on that directory?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 12

Expert Comment

by:mccracky
ID: 35009907
If you can ssh in with the keys, then scp is no different and the problem shouldn't be the keys.  

To try to troubleshoot, you might try using filezilla from the linux side as it can use ssh for the transfer (similar to winscp from windows).
0
 
LVL 1

Author Comment

by:hdaz
ID: 35010090
@t-max

always taken me to

ssh -p 9090 root@192.168.0.210
Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>

Iv not ssh-ed in for a while, this time it seems locked solid, the last time i did a dir, but due to the console being very hard to read, i.e. it was over the top of previous Linux commands did not try much else...

just tried twice and both times locked solid at C:\Windows\system32>
0
 
LVL 6

Expert Comment

by:t-max
ID: 35010270
Well, that might be the problem.

\Windows\system32 is a special folder, and not everyone has rights to write inside it.
Can you change the home directory for the root user in the freesshd?
I would try creating a folder c:\root, with full permissions to everyone.
If that works, permissions and default home directory was your problem.
0
 
LVL 1

Author Comment

by:hdaz
ID: 35010446
After playing with freeSSHD settings I can log in and create a file

echo test123 > test.txt

C:\Windows\system32>dir test.txt
 Volume in drive C is System
 Volume Serial Number is 42CC-DBA7
                                                                               st 643860771
 Directory of C:\Windows\system32

01/03/2011  18:35                10 test.txt
               1 File(s)             10 bytes
               0 Dir(s)  50,719,567,872 bytes free


The above was via Password stored as SHA1 --- and manually entering the password.

doing anything via

scp with the same settings as ssh(es) above shows

debug1: Sending command: scp -v -t /
debug2: channel 0: request exec confirm 0
debug2: callback done
debug2: channel 0: open confirm rwindow 131072 rmax 98304
debug2: channel 0: rcvd close
debug2: channel 0: output open -> drain
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
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
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.0 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status -1
lost connection

as if no shell is being established correctly....

going back to the end of the string ".210:/Desktop/" might be the reason / logic?
0
 
LVL 1

Author Comment

by:hdaz
ID: 35010530
Looking at the logging from freeSSHD


03-01-2011 18:55:05 IP 192.168.0.xxx SSH root successfully logged on using password.
03-01-2011 18:55:10 IP 192.168.0.xxx SSH root disconnected.


0
 
LVL 12

Expert Comment

by:mccracky
ID: 35011168
Can you connect and do it with filezilla?  With password?  With keys? It might help with the troubleshooting.
0
 
LVL 1

Author Comment

by:hdaz
ID: 35011382
Just tested from home as I set it up on one of my machines over a year ago....

the answer is to forget about scp and use sftp... doing this on XP works well...

I'll update this tomorrow if I am right and there are no other complications...

Thanks
hdaz
0
 
LVL 1

Accepted Solution

by:
hdaz earned 0 total points
ID: 35011733
OK this looks perfect... using sftp I worked out what the file path should be..
lpwd and pwd

scp -P 9090 file2send user@WinServ:/home/user/

so in my case the scp will be
scp -P 9090 root@WinServ:/home/root/

hdaz
0
 
LVL 6

Expert Comment

by:t-max
ID: 35012238
That's great news!
Indeed it was problematic to use "root@winserv:" because you don't specify any path. In a linux box that's translated to the user's home directory, but it seems freesshd has some problems without it. Cheerz!
0
 
LVL 12

Expert Comment

by:mccracky
ID: 35012513
Good news that sftp helped work things out.
0
 
LVL 12

Expert Comment

by:mccracky
ID: 35363612
Since it looks like comment 35011168 suggesting filezilla (sftp) helped solve the problem, it should probably be given a share.
0
 
LVL 1

Author Comment

by:hdaz
ID: 35364899
Just out of interest I did not use filezilla i just used SFTP command line which syntax is different than scp's.

I still prefer to use scp and I wanted to modify Windows in order to achieve my goal. so far that's not been 100% possible.

my alternative is to use CYGWIN instead of FREESSHD if all efforts fail with FREESSHD.
0

Featured Post

Want to promote your upcoming event?

Are you going to an event? Are you going to be exhibiting at a tradeshow? Talking at a conference? Using a promotional banner in your email signature ensures that your organization’s most important contacts stay in the know and can potentially spread the word about the event.

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now