# How to transfer files from windows-box to linux-box

## JukkaR

I have all my mp3's on my windows-bx and I would like to transfer them to computer using Gentoo Linux. Computers are connected via hub (manufactured by Askey). Both computers have Realtek network cards (driver module: 8139too). There's a network of three computers, it's some kind of windows-network. Internet works normally through the hub, there's adsl modem net connection.

----------

## rickysilk

You'll want to emerge samba on your linux box.

http://www.samba.org/

----------

## rizzo

Or if don't want to emerge samba you could just scp.  Probably download Putty's pscp for windows and then:

pscp -r <mp3 dir> <username>@<linuxboxname>:<destination>

But emerging samba and using it like a writable windows share would be easier.

----------

## JukkaR

 *rizzo wrote:*   

> Or if don't want to emerge samba you could just scp.  Probably download Putty's pscp for windows and then:
> 
> pscp -r <mp3 dir> <username>@<linuxboxname>:<destination>
> 
> But emerging samba and using it like a writable windows share would be easier.

 

I downloaded pscp, but when I'm trying to transfer files, it ask for root's password.. (I have only root account on my linux).. When I type the password, it asks it again - for seven times, then it stops. No files were transfered. 

Now, do I have to compile something to kernel - again.. I'm getting a bit bored for such things...

----------

## rizzo

Do you allow remote root logins?  Check your /etc/ssh/sshd_config for the line that says "PermitRootLogin".  I think it defaults to yes, but that is something to check.

----------

## JukkaR

 *rizzo wrote:*   

> Do you allow remote root logins?  Check your /etc/ssh/sshd_config for the line that says "PermitRootLogin".  I think it defaults to yes, but that is something to check.

 

It was yes but it was commented. Ok, I uncommented - didn't work.

----------

## rizzo

Hmm then the only thing I can suggest is that you were entering the incorrect password.  Check caps lock etc.

You shouldn't need to do any kernel changes for this, so don't worry there.

----------

## n0n

I'd create a user account on the box to see if that works . . .  (Edit: Here I originally said "make sure the user is in the 'wheel' group otherwise it won't work," but I was wrong because I had that confused with another problem.  Apologies.)

Also, I've had problems with pscp occasionally.  A better solution, methinks, is to load up the Cygwin project on your Windoze box, at http://sources.redhat.com/cygwin.  Basically, it's a port of a LOT of GNU and open-source software to Windows, so you can actually use bash in an xterm on Windows, compile programs with gcc, and (here's the important bit for this discussion) use OpenSSH.  And I'd use OpenSSH if I were you.  The first thing I do when I have to work on a windoze box is install Cygwin, and then I feel right at home.Last edited by n0n on Wed Aug 28, 2002 7:22 pm; edited 1 time in total

----------

## n0n

Ah, I am reminded after reading this topic of another thing that might be going on here.  In the file /etc/passwd, the last field defines the user's shell.  On the default Gentoo installation, if I remember correctly (it's been some time), this field is left blank, which ordinarily isn't a problem, because it'll just start you up with that shell.  But SSH requires that you have an entry in there.  So I'd check /etc/passwd and if "/bin/bash" isn't at the end of root's entry, add it.

(Still, you'd think that you'd get an error other than "Invalid password" if this were the case - but it's worth a look, anyway.)

----------

## pilla

Have you restarted sshd after that? 

/etc/init.d/sshd restart

 *JukkaR wrote:*   

>  *rizzo wrote:*   Do you allow remote root logins?  Check your /etc/ssh/sshd_config for the line that says "PermitRootLogin".  I think it defaults to yes, but that is something to check. 
> 
> It was yes but it was commented. Ok, I uncommented - didn't work.

 

----------

## JukkaR

Now I tried samba... Everything gone perfectly until I had to enter my samba-password. Entered it and Windows prompted: "Salasanasi on väärä. Yritä uudelleen", - Your password is wrong. Try again. I tried, with and without encrypted password -option in smb.conf, tried root's password - nothing. Well, atleast Windows-box now notices that theres Localhost connected in the network.. Do I have to buy cds and burn the damn mp3s and get them to the other computer that way...

In the /etc/passwd -file I checked that there was bash defined - was.

Does pscp even work with OpenSSH 3.4 ? On my computer, ssh isn't started automatically at boot. I have to type /etc/init.d/sshd start .

BTW, now I get this kind of error using pscp:

Fatal: ssh_init: Network error: Connection refused 

 - Atleast something new.....

Is there any program for linux that could connect to the network, since programs in Windows are not accepting my passwords..

----------

## n0n

 *JukkaR wrote:*   

> I tried, with and without encrypted password -option in smb.conf, tried root's password - nothing.

 

Did you restart Samba inbetween changing those configuration options?

 *JukkaR wrote:*   

> Does pscp even work with OpenSSH 3.4 ?

 

Yeah, I've done it.  Both pscp and OpenSSH 3.4 speak SSH Protocol Version 2.  Any SSH2-capable client would be able to talk to any SSH2-capable server.  Both pscp and OpenSSH3.4 speak version 2.

 *JukkaR wrote:*   

> On my computer, ssh isn't started automatically at boot. I have to type /etc/init.d/sshd start.

 

Run this command as root on your Linux box:

```
rc-update add sshd default
```

This will add "sshd" to the list of programs that get started at the "default" runlevel.

 *JukkaR wrote:*   

> BTW, now I get this kind of error using pscp:
> 
> Fatal: ssh_init: Network error: Connection refused 
> 
>  - Atleast something new.....

 

That's interesting.  To me, that says that SSHd isn't running on the box the way it should be.  On the Linux box, do:

```
netstat -an | grep LISTEN
```

You should see a line that looks like this:

```
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
```

Port 22 is what SSH listens on, and the * tells you that it's listening to anyone who cares to find it.  If you don't see that line, then SSHd isn't actually listening.  (Alternate methods of finding this out: emerge nmap, and then do "nmap localhost" - that's a port scanner that'll tell you what ports are open on your box, or do "fuser -vn tcp 22" which will tell you what process is using up port 22 on your box . . .)

----------

## n0n

 *I wrote:*   

> Make sure that you add the user to the "wheel" group, otherwise they won't be able to log in . . .

 

Uh, no, I lose.  The "wheel" thing is to allow users to su to root, not to log in with SSH.  Just the thing with the /bin/bash applies here.  Apologies about that.

----------

## JukkaR

 *n0n wrote:*   

> Did you restart Samba inbetween changing those configuration options?

 

Yes

 *n0n wrote:*   

> That's interesting.  To me, that says that SSHd isn't running on the box the way it should be.  On the Linux box, do:
> 
> ```
> netstat -an | grep LISTEN
> ```
> ...

 

I can see that line, and "fuser -vn tcp 22" gives line:

```
22/tcp         root            4232           f......            sshd
```

----------

## n0n

Hm.  Well, here's some more ideas, then.  Try doing an "iptables -L" to see if there's any rules blocking SSH traffic or something (probably you won't see anything there, though).  I'm sure there are some port scanners available for Windows; perhaps try scanning your Linux box from there.  Make sure you don't have any firewalls or something running on your Windows box (and if you do, make sure that's not what the problem is).  Try ssh-ing into the box, instead of doing a file transfer - perhaps there's something wrong with just the file transfer side (use PuTTY or openssh via Cygwin to do that on Windows) . . .

----------

## JukkaR

 *n0n wrote:*   

> Try doing an "iptables -L" to see if there's any rules blocking SSH traffic or something (probably you won't see anything there, though).

 

Typed iptables -L and got this:

```
modprobe: Can't locate module ip_tables

iptables v1.2.6a: can't initialize iptables table `filter': iptables who? (do you need to insmod?)

Perhaps iptables or your kernel needs to be upgraded.
```

Is there any program that could connect FROM linux TO windows. I would like to try it that way...

----------

## n0n

 *JukkaR wrote:*   

> 
> 
> ```
> modprobe: Can't locate module ip_tables
> 
> ...

 

Okay, so you don't have iptables running, then, because the kernel modules don't exist.  That can't be the problem, then.

 *JukkaR wrote:*   

> Ok, seems that it's not possible to transfer files from windows to linux.. Maybe I should reinstall XP...

 

Of course it's possible to transfer files from windows to Linux.  I do it all the time.  You're probably just feeling a bit frustrated because you're working in a completely different environment than you're used to, and things don't work the way you might expect them too.  Keep at it!  Once you figure everything out, it's great.

Now, did you try the other suggestions I had?  Perhaps if you could post a transcript of the failed file transfer session (ie: everything you see from the command prompt) would help.

----------

## JukkaR

I'm not sure about the firewalls.. My target is not to connect the linux computer permanently to the network, I just have to transfer the mp3s and some other files to linux. I'm getting pretty sure however that the problem isn't in the linux, I think problem's in windows system. If I type

```
pscp -v c:\linux\*.* xyz@localhost.localdomain.com:/home
```

, it asks for xyz's password - my Linux-box hasn't user called 'xyz'. There's F-Secure Management Agent, Anti-Virus and BackWeb running on windows box. They can't be permanently stopped.

----------

## n0n

You said that you've only got the root user, right?  Make sure you're using "root" instead of "xyz" in that case.  I'd also recommend is simplifying the command line just a bit.  Try something along these lines:

```
c:

cd linux

pscp this_one_file.mp3 root@linuxbox:/root
```

Just trying the one file at a time would make sure that it's not having problems with the multiple files.

----------

## JukkaR

 *n0n wrote:*   

> You said that you've only got the root user, right?  Make sure you're using "root" instead of "xyz" in that case.  I'd also recommend is simplifying the command line just a bit.  Try something along these lines:
> 
> ```
> c:
> 
> ...

 

Yes, I've tried using root-account, 'xyz' was just an expirenment - I though that when it asks password for user that doesn't even exist, it haven't connected at all.

----------

## Zu`

 *rizzo wrote:*   

> Or if don't want to emerge samba you could just scp.  Probably download Putty's pscp for windows and then:
> 
> pscp -r <mp3 dir> <username>@<linuxboxname>:<destination>
> 
> But emerging samba and using it like a writable windows share would be easier.

 

Not quite.

There is a great GUI frontent to scp for Windows: WinSCP

This way you can drag and drop files from your Windows box to your linux box using nothing but SSH.

I found it to be very useful for people used to using Windows.

Screenshot:

[img:3b262b1270]http://winscp.vse.cz/eng/screenshots/small/commander.gif[/img:3b262b1270]

----------

## rizzo

 *n0n wrote:*   

> 
> 
> ```
> c:
> 
> ...

 

pscp this_one_file.mp3 root@linuxbox: will default to the users' home directory, in this case /root.  Note that you DO need the colon.

----------

## JukkaR

Unfortunately, using Winscp, there's the same problem. When I enter the password, it just asks it again. But it doesn't log in.

----------

## Zu`

 *JukkaR wrote:*   

> Unfortunately, using Winscp, there's the same problem. When I enter the password, it just asks it again. But it doesn't log in.

 

So you can't login remotely using SSH?

Even not on the box itself?

```

ssh user@127.0.0.1

```

----------

## Zu`

 *JukkaR wrote:*   

>  *rizzo wrote:*   Do you allow remote root logins?  Check your /etc/ssh/sshd_config for the line that says "PermitRootLogin".  I think it defaults to yes, but that is something to check. 
> 
> It was yes but it was commented. Ok, I uncommented - didn't work.

 

It was commented because all the default settings are commented. You only need to uncomment something if you want to change the default values.

----------

## Zu`

 *JukkaR wrote:*   

> Unfortunately, using Winscp, there's the same problem. When I enter the password, it just asks it again. But it doesn't log in.

 

If SSH works fine but SCP doesn't, check out this from the OpenSSH FAQ:

http://www.openssh.org/faq.html#2.9

See if this outputs anything:

```

ssh yourhost /usr/bin/true

```

----------

## JukkaR

 *Zu` wrote:*   

>  *JukkaR wrote:*   Unfortunately, using Winscp, there's the same problem. When I enter the password, it just asks it again. But it doesn't log in. 
> 
> So you can't login remotely using SSH?
> 
> Even not on the box itself?
> ...

 

Nope. I cant login even in the box itself.

My /etc/hosts -file:

```
127.0.0.1          localhost

64.211.252.76        localhost.localdomain.com           localhost
```

Would there be something wrong in that file?

----------

## rizzo

Yes that file is wrong.

The 127.0.0.1 line is fine.  The second line should resolve to what your actual resolvable machine name is.  By that address I am understanding that your gentoo box has a static IP on the internet and is not behind a NAT router?

So an example would be:

```
64.211.252.75     machinename.mydomain.com     machinename
```

----------

## kengu

wouldn't it just be easier to use FTP?

----------

## n0n

Possibly.  You've still got to set up the FTP server, though, and FTP sends passwords in plaintext, which makes them very vulnerable to sniffing.  And while that might not be a concern in this case (I don't know whether these machines are on a public network or not), I feel that it's a good idea to get into the "habit" of security early, so you don't have to re-learn things when it does become an issue.

That said, FTP certainly does have uses.  I've got proftpd installed on my Gentoo box which I occasionally turn on so that my girlfriend can transfer some files from her Mac (os9) which I haven't tried to integrate any other way.  I protect the port with iptables so that it's only accessible from her computer, and it's just an anonymous site, so there's no passwords sniffable anywhere.

That said, (*grin*) this is by far the most problems I've ever had setting up SSH.  Typically I just install openssh and the client wherever it needs to go, and things just work.  :)

----------

## rizzo

I think the fact that he cannot even ssh to his box should be the main focus now.

Please confirm that you have ssh running

```
ps auwwwx | grep sshd
```

should return a line like this

```
root      2797  0.0  0.1  2692 1016 ?        S    Aug17   0:02 /usr/sbin/sshd

```

What errors do you get when trying to ssh (not scp) to that box?

----------

## scheuri

 *kengu wrote:*   

> wouldn't it just be easier to use FTP?

 

thanks kengu...

you jsut said what I thought first reading this thread...  :Wink: 

honestly...as long as it is not necessary to encrypt the username/login and the content, why bothering with scp, ssh in general or something else than FTP?

first make your machine answering FTP-requests

then download a nice GUI for windows (Cute_ftp or WS_FTP) and then try to connect to the linux-machine...

my 2 rappen

scheuri

----------

## rizzo

Mainly because of the fact that I don't think this kid has any clue about networking given the current state of affairs.  So I would like to set him off on the right path with ssh/scp rather than the VERY insecure and VERY exploitable telnet and ftp.

Guessing from his previous post, I interpret that his linux box is indeed directly on the internet and so I would NEVER telnet/ftp to it.  Especially now that he has posted his IP and any one of a million trolls is sniffing traffic as we speak.

----------

## scheuri

 *rizzo wrote:*   

> ... rather than the VERY insecure and VERY exploitable telnet and ftp.
> 
> Guessing from his previous post, I interpret that his linux box is indeed directly on the internet and so I would NEVER telnet/ftp to it.  Especially now that he has posted his IP and any one of a million trolls is sniffing traffic as we speak.

 

(did some shortage with your quotes)

Well, okay...granted...though FTP would still be the easiest thing...however...you are right...under these circumstances better teach hin the right thing/way

I actually wasn't aware he was giving out his (fix?) IP-adresse (from his ISP?)....which indeed wouldn't be that fun (for him)....

anyway...still thinking of FTP...he might disconnect (physically) himself from the internet, open the FTP-port and then transfer his MP3, close the port again and then connect himself again to the internet...

just to give him the possibility to read som man's about ssh and scp while listening to music....  :Wink: 

my 2 rappen (which are cents in switzerland)

scheuri

----------

## rizzo

Granted I don't _know_ for sure, but I'm assuming from his hosts file that he posted above.

I don't think FTP would be any easier than ssh/scp.  I didn't have any trouble getting it going.

```
emerge openssh

rc-update add sshd default

/etc/init.d/sshd start
```

and I was golden.  Jukkar do these steps in order again and tell me what output you get.

----------

## JukkaR

First the problem was that there wasn't even sshd running on my machine. And the fact is that I don't know anything about these network issues. What there should be in the etc/hosts file below line "127.0.0.1     localhost"? 

There's currently only mymachine.mydomain.com         mymachine, since I dont know what IP-address there should be. And in pscp, is it correct when I type pscp file.txt root@mymachine.mydomain.com:/home ? Currently, I can login to my own box, typing ssh root@127.0.0.1 .

----------

## rizzo

Alright I think we need more background.

I was under the impression that you have two machines.  One is a windows machine, and the other is your new gentoo machine.  I was also under the impression that both machines were directly connected to the internet, that both had real (i.e. resolving) IP addresses.

Please tell us how you are connected to the internet.  DSL, Cable, dial-up?  Do you have a router that shares the internet connection doing NAT?

This is not a problem with ssh at all.  I would bet this bag of pretzels that I'm enjoying (honey mustard) that this is a network configuration problem and we'll do our best to educate you on such matters.  Give us as much information as possible about your network setup and internet connection and we should be able to start.

----------

## JukkaR

 *rizzo wrote:*   

> Alright I think we need more background.
> 
> I was under the impression that you have two machines.  One is a windows machine, and the other is your new gentoo machine.  I was also under the impression that both machines were directly connected to the internet, that both had real (i.e. resolving) IP addresses.
> 
> Please tell us how you are connected to the internet.  DSL, Cable, dial-up?  Do you have a router that shares the internet connection doing NAT?
> ...

 

Three computers, they are all running Windows. (I've stolen one of the windows computer's network connection, because there's no more than three computers that can be connected to router.) Internet connection is shared for these three computers. So there's this kind of connection: In my computer (gentoo), there's network card (module=8139too, Realtek) that is connected to the router with those two windows computers. And the router is connected to Adsl modem. I could connect my computer and the windows computer (where the files are that need to be transfered) directly  to each other (they are on same table). I don't know what is NAT ...

When I start samba, the windows-computer notices that theres "mymachine" online, type=samba server 2.2.5 . But when I double-click on the "mymachine", it asks for the passwd. But it won't accept it.

Typed pscp -v file.txt root@mymachine.mydomain.com:/home , and it tries to connect 216.148.221.139 port 22 - an IP-address that I haven't defined anywhere.

----------

## n0n

Okay, check this . . .  On your Linux box, make sure networking works (ping some addresses, maybe visit a webpage or two).  Then get your IP address ("ifconfig eth0" will tell you this, among many other ways).  Then, on your windows box, do:

```
pscp a_file_in_my_current_directory.mp3 root@<ip-address>:/root
```

"mymachine.mydomain.com" is currently defined in /etc/hosts on the Linux box, this makes it only active on that Linux box.  Just ignore it for now and use an IP address to see if that works.  The reason why SAMBA is noticing "mymachine" is because of Samba setup.  It doesn't make the "mymachine.mydomain.com" address resolvable via dns . . .

----------

## rizzo

Alright then I'm going to assume that you have no idea what IP addresses are, and that you have been interacting with your windows boxes only through the Windows networking crap.

If you want to continue to do this, then samba could do that for you.

If you want to get off the porch and run with the big dogs, continue reading.  I'm sure there are a million HOWTOs that explain things, but I'll try to be concise.

I'm assuming that your DSL provider (mine is SBC) gives you only 1 IP address.  You need an IP address to be able to do anything on the internet.  If you have more than one computer, you use a router to handle this IP address and share it via things like IP Masquerading and Network Address Translation (NAT).  If you are interested read this

Now your computers behind the router also have IP addresses, but they have what are called non-resolving IP addresses.  There are certain ranges of IP addresses that are reserved for intranet use.  I think they are 10.*.*.*, 192.168.*.*, and 172.16.*.*.  Someone correct me if I'm wrong.  Now I'm willing to bet that your router is also DHCP server that is assigning your computers one of these addresses.  What you need to know is what address it is assigning you.

So log into your linux box as root and type "ifconfig eth0" and find the "inet addr".  That is your IP address for talking between each of your LAN machines.  So if your IP is 192.168.0.2, then on your windows box you could type:

```
pscp -r mp3 root@192.168.0.2:
```

And that would move a directory named "mp3" to your gentoo box and put it in root's home directory (normally /root).  NOTE that you need the colon ":" at the end of that line.  pscp is nice and will just fail and give you a warning if you don't have it.  scp on linux will actually copy the file to a file named root@192.168.0.2 if you don't have it.

Good luck and God speed.Last edited by rizzo on Fri Aug 30, 2002 4:12 pm; edited 1 time in total

----------

## JukkaR

PROBLEM SOLVED!! Typed ifconfig eth0, took ip-address from there and entered it to pscp - now files are trasfered !! Thank you very much for your patience and help. I really appreciate that.

Edit: Files are not transferd, they are being transfered - it's over 12 gb's of them... It's going to take a while (almost 5h), since the network does only 700 kb/s.Last edited by JukkaR on Fri Aug 30, 2002 4:36 pm; edited 2 times in total

----------

## rizzo

Ah cool.  Sorry if I dumbed it down too much, better safe than sorry.

Anyway like I said ssh/scp is the way to go.  NEVER use telnet/ftp if you don't have to.  And if you have to, then bitch about it until they put ssh on.

----------

## pilla

It is also a good idea to disable Protocol 1 in SSHD... it is weak and somebody sniffing your network can get your password, I think. You can do that in /etc/ssh/sshd_config

```

Protocol 1,2

```

Change it to 

```

Protocol 2

```

Don't forget to restart your ssh server.

 *rizzo wrote:*   

> Ah cool.  Sorry if I dumbed it down too much, better safe than sorry.
> 
> Anyway like I said ssh/scp is the way to go.  NEVER use telnet/ftp if you don't have to.  And if you have to, then bitch about it until they put ssh on.

 

----------

## rizzo

Yes I agree I forgot about that.  I only use protocol 2.

Thanks B

----------

