Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Net::FTP Help

by cybear (Monk)
on Aug 26, 2002 at 16:07 UTC ( #192919=note: print w/replies, xml ) Need Help??


in reply to Net::FTP Help

I don't know of anyway to "SU" when using FTP. The FTP server on my Solaris
server will not recognize the "su" command, no matter how I issue it.
There is no way of sending the password to "su" as a command line parameter
anyway. So... I don't think that you will get this to work.

Here is a work-around. Use Net::Telnet to start a telnet session, su to root
in that telnet session, then as root:

1) the untested version:
start an ftp session and set it to display on your terminal.
example: ftp someserver.com -display your.ip.add.ress:0.0
this may not work and you need to have a way of displaying the incoming
data. i.e. you need to be on a unix machine running Xwindows,
or have an emulator running.

2) the tested verions:
start a shell session, /usr/bin/sh for example, and display it to your
terminal. /usr/bin/sh -display your.ip.add.ress:0.0
correction=>after the shell shows up on your system, use it to ftp to your machine
same rules as above, you will need to be on a unix machine running Xwindows
or have an emulator running.

Good Luck

- cybear

Replies are listed 'Best First'.
Re: Re: Net::FTP Help
by waswas-fng (Curate) on Aug 26, 2002 at 16:37 UTC
    Absolutely no idea what you are talking about there:
    ftp someserver.com -display your.ip.add.ress:0.0
    You seem to be confusing ftp and sh with X apps. FTP (unless you have some goofy replacement ftp client like mftp or something renamed as ftp in your path) is not graphical and the –display flag will just error out on you. Your solution will not work and really does not answer this posters problem.

    On to the problem, the original poster is confused between telnet and FTP. FTP is File Transfer Protocol; there is no su command for FTP. You have two (or maybe even more) issues here.

    First, Net::FTP will allow you to connect to a remote FTP server and login, upload and download files list directories and so on. If this is not what you are looking for then you need a different module.
    Second After reading your question I think I can pull out what your problem is, you are trying to use Net::FTP to connect to a ftp server, you are trying to login to the ftp server as root and since /etc/ftpusers (or wherever the file that accomplishes the same thing is on your ftp server) has a “root” entry you can't log in as root. Why do you need to log in as root? FTP auth is all plain text and anyone on your network could snoop your root password – root login via FTP is a _BAD_ idea. I would take a step back and think about what you are trying to accomplish. Do you really need root access to push or pull the files from that server? If the answer is yes I would consider using the SCP mods to do so. SCP uses encrypted logins and file transfers. If the answer is no I would set up the push or pop locations to be usable by a non system user and do the transfers that way. If you feel like your really _MUST_ login as root directly with FTP then (depending on the ftpd your system uses – some are hard coded not to allow root logins ever) you may edit the file /etc/ftpaccess on the ftp server and remove “root” from the file. That will allow you to login as root with FTP. If you choose the last approach there is something wrong with you. =)

    -Waswas
      Sorry for the confusion... let me be more precise.

      I have effectively beaten the same limitation that is sited in the original post.
      You need to be on a unix/linux workstation running Xwindows, or you need to have
      an Xwindows emulator, such as eXceed, running on your Windows/Mac workstation. Then...

      Write your Perl script to use Net::Telnet. Log in to the remote machine. Then "su" to root, /usr/bin/su - root
      as root have your script start a shell session /usr/bin/sh -display what.every.your.ip
      and pass it the "display" parameter. This WILL send the output from the shell to the IP address
      that you specify.

      Once your shell window opens up on your workstation, you can have your script start ftp. You will be
      starting FTP as root. The main diffrence will be that you must put instead of get.

      disclamer: this will not work "server-to-server". This will only work, as discribed, if you are
      trying to connect from a workstation, running unix/linux, or a workstation running an Xwindows
      emulator... but it absolutely does work.

      - cybear

        Sorry, cybear, but Net::Telnet has the same problem as Net::FTP does: it will send your root password across the wire in clear text.

        If you're going to try to do something like this, please use Net::SSH or Net::SSH::Perl.
        --
        Mike

        bah, let me be more precise.

        [DING!] 1 [~]:msp-mainserver% /usr/bin/sh -display www.myhost.com:0.0 -display: bad option(s) [12:00pm] 2 [~]:msp-mainserver% /usr/bin/ftp -display www.myhost.com:0 +.0 ftp: s: unknown option
        Command line programs dont have a -display command line flag, You are seriously confused. /usr/bin/sh and ftp are not gui on any system I have ever worked on (Solaris, any distro of linux, aix, hpux, irix etc). but it absolutely does work. on what unix? I think not.

        -Waswas

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://192919]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2018-04-27 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?