📄 install.txt
字号:
install.txt version 1.09Installation instructions for sftpd-----------------------------------These instructions setup sftpd to intercept all normal ftp trafficand secure the connections made by secure (SafeTP) clients.Following all of these instructions will require root access (thoughthe daemon itself does not run as root). However, a limited form ofsftpd (specifically, where it listens to a nonstandard, unpriviledgedport) may be installed without root access.1. Create 'safetp' user.Create a 'safetp' user, in whose name the sftpd daemon will run. OnLinux, this is accomplished through the 'adduser' program; it might becalled "useradd" elsewhere.safetp's home directory must be on the local disk. Sensitiveinformation is stored there, and it is a serious security risk forthis information to go over the network in the clear. Make sure readand write access to this directory is limited to just its owner.If your system has provisions for giving certain users even *less*authority than normal users, you may want to so limit 'safetp'.safetp only needs to be able to read and write files in his homedirectory (and the DSA subdirectory thereof), make outgoing TCPconnections, and listen to unpriviledged TCP ports.The actual name of the created user can be anything.2. Compile the binariesAt UCB, in the CS dept., the binaries should already be available,in /usr/sww/pkg/safetp. Skip to step 3.Otherwise, see compile.txt.3. Run the install script.As root, run: # sc/install.plIf all goes well, you're done. If not, there are sometroubleshooting tips in trouble.txt.------------------------------------------------------------------------ Manual install instructions -------------------------------------------------------------------------------------------------These instructions should be unnecessary, as the 'install' scriptsupercedes them. They may also be somewhat out of date. They arehere to give a (more) readable account of what the install scriptdoes, and some additional info on troubleshooting, etc.Note on naming: The daemon for SafeTP is called 'sftpd'. "sftp" is,however, the name of some unrelated service, usually at port 115.I will use the term "sftpd" when referring to the SafeTP daemon program, "SafeTP" when referring to the system as a whole, and "safetp"to refer to the user we recommend you create and the name of theservice sftpd will query to determine a port number to listen to.Outside this paragraph, I am never referring to the port-115 "sftp".(In this document, "quotes" refer to the string of characters, and'ticks' refer to the entity named.)Permissions summary after installation is complete:NOTE: All files must be owned by 'safetp'. min for safetp operation safe, convenient ~safetp drwx------ drwxr-xr-x ~safetp/randomSeed -rw------- -rw------- ~safetp/DSA drwx------ drwx--x--x ~safetp/DSA/private.key -rw------- -rw------- ~safetp/DSA/public.key -rw------- -rw-r--r-- (wherever)/public.key.txt (not needed) -rw-r--r--1. Setup the binaries.1.1 (OPTIONAL) Create a 'safetp' user, in whose name the sftpd daemonwill run.On Linux, this is accomplished through the 'adduser' program (same onmost Unix?).Make sure read and write access to this directory is limited to justits owner. If your system has provisions for giving certain userseven *less* authority than normal users, you may want to so limit'safetp'. safetp only needs to be able to read and write files in hishome directory (and the DSA subdirectory thereof), make outgoing TCPconnections, and listen to unpriviledged TCP ports.The actual name of the created user can be anything.It may be useful to add 'safetp' to the 'daemon' group, so its filescan be marked with this group, rather than 'users'. This is doneby modifying the /etc/group file (more complicated on yp systems,I don't know the details), adding "safetp" to the "daemon" line, andchanging the default group of "safetp" in /etc/passwd.This is a security measure; it is not required for functionality.If you're at U.C. Berkeley, you can use the prebuilt binaries; go tostep 1.2(b). Otherwise, go to step 1.2(a).1.2(a) Copy the sftpd sources into ~safetp, and build them.See compile.txt.1.2(b) Copy the sftpd binaries from sww to the local disk.The sftpd binaries are in /usr/sww/pkg/safetp. The important binariesare: sftpd the daemon proxy itself makekeys for creating new keys viewkey for viewing keys and checksums addent for manually adding entropy sftpc the unix client1.3 Make a new server keypair.From safetp's home directory, while logged in as user 'safetp', do this: % makekeys 0 1024This will ask you for a server name to "brand" the public key, thento type a bunch of characters to add entropy to the system. (Thedots have to get most of the way across the screen.)In this process, you are creating a new DSA (Digital SignatureAlgorithm) public and private key. makekeys is also capable ofgenerating ElGamal keys, but the server does not need to have itsown ElGamal keys (that is why the first argument is "0").The DSA keys are stored in the DSA subdirectory, as DSA/public.keyand DSA/private.key. The public key should be made available;the private key must be kept secret.To make the public key available to users out-of-band, this is therecommended procedure: (from ~safetp) % viewkey DSA/public.key > DSA/public.key.txt % chmod a+r DSA/public.key.txt % chmod a+x DSAThen, some system-wide information service (motd, perhaps) can pointusers to ~safetp/DSA/public.key.txt .This process also writes the state of its pseudo-random numbergenerator to a file called "randomSeed". The contents of thisfile must also be kept secret, and 'safetp' must always havepermission to read and write this file.1.4 (OPTIONAL) Test sftpd.While logged in as an ordinary user (not safetp or root), create a setof client keys. % makekeys 1024 0 (more entropy typing required....)Run sftpd in a shell window, with priviledges to access randomSeed andDSA/{public,private}.key . # sftpd -p2123 -f21Run sftpc in the shell window where you just created client keys. % sftpc -p2123 (Supply the -s<hostname> argument if the host is nonlocal.)Enter your username and password at the next two prompts.Then, once you get the "sftpc>" prompt, type these things: 1. tests // should end with "(files are identical)" printed 2. quitIf all goes well, no exceptions will be thrown.2. Modify system configuration files.2.1 Modify /etc/services so sftpd listens to 21 and ftpd is elsewhere./etc/services maps port numbers to named services. Find a line inthis file like this:ftp 21/tcpModify it (adding "safetp" as an alias), and add another:ftp 21/tcp safetpraw-ftp 221/tcpHere, 221 is where I've put ftpd. It can be any value, but should notcollide with preexisting port number conventions, and should be lessthan 1024, so ordinary user processes cannot masquerade as ftpd.There is a potential problem here if 'ftpd' is run as a stand-alone daemoninstead of by inetd. Since ftpd, in this mode, queries getservbynamefor "ftp", it will listen on the same port as sftpd. At this time, Idon't know a good workaround (other than next paragraph).It is possible to run sftpd on a port other than 21, but in that caseusers would have to explicitly tell their clients which port to use,thereby reducing the likelihood of use.2.2 Modify /etc/inetd.conf to run sftpd in response to a connect onport 21.2.2.1 Add 'sftpd'.Add a line like this (it is split onto two lines for readability):safetp stream tcp nowait safetp /home/safetp/sftpd sftpd -s -y/home/safetpThe "-s" is critical; it tells sftpd it's being run by inetd. Info onother options can be viewed by running "sftpd -h". Note thatinetd.conf *includes* argv[0], which is why the first argument is"sftpd".The "-y" changes sftpd's current directory. This should be thedirectory of which DSA is a subdirectory, and where randomSeed lives.(On some systems, it is redundant; on others, it is required.)Note: For maximum security, you can disable the 959 dropdown bysupplying the "-9" option to sftpd. Doing so disallows insecureconnections.2.2.2 Modify 'ftpd'.Change the existing ftpd line, so it is run in response to a connecton the 'raw-ftp' port instead of the 'ftp' port:raw-ftp stream tcp nowait root /usr/sbin/tcpd wu.ftpd(This is a line from my Linux inetd.conf, which by default usestcpd for connection logging and control. sftpd is also compatiblewith tcpd, though in my examples I've not been using it.)2.2.3 HUP inetd to re-read inetd.conf.You'll have to then cause inetd to re-read its configuration file.This is done by sending the "HUP" signal to it. On Linux, thisis easy: # killall -HUP inetdOn other systems be careful, sometimes 'killall' does what it soundslike it does.2.3 (OPTIONAL) Modify /etc/syslog.conf, if desired.sftpd generates syslog messages while running. All messages areof the 'daemon' facility. Routine logging is in the 'info' class,and if the "-d" switch is specified, additional detail is specifiedwith the 'debug' class.Logging of file-level info, like per-transfer logs, is left toftpd (since it will be involved in every file transfer, as usual).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -