Building a Chrooted sftp Environment on Linux

2016-01-29 18:30 5 1 收藏

Building a Chrooted sftp Environment on Linux,Building a Chrooted sftp Environment on Linux

【 tulaoshi.com - Linux 】

There was a time, not so very long ago, when we used to enjoy running an ftp server and locking our users into tiny little chrooted jails. While we still enjoy denying users their freedom, we now prefer to do so using a maximum security facility. The sftp file transfer program, which comes with OpenSSH server, gives users an interactive interface like ftp but performs transfers over an encrypted ssh transport. In this day and age, it is not unreasonable to expect users to start using an ssh client, even if they are running Windows. If they don't have one already, tell them to download Putty. There are also nice commercial clients, and if users are technically adept and so inclined, they can use openssh over cygwin
Building a Chrooted sftp Environment - Printable ViewThere was a time, not so very long ago, when we used to enjoy running an ftp server and locking our users into tiny little chrooted jails. While we still enjoy denying users their freedom, we now prefer to do so using a maximum security facility. The sftp file transfer program, which comes with OpenSSH server, gives users an interactive interface like ftp but performs transfers over an encrypted ssh transport. In this day and age, it is not unreasonable to expect users to start using an ssh client, even if they are running Windows. If they don't have one already, tell them to download Putty. There are also nice commercial clients, and if users are technically adept and so inclined, they can use openssh over cygwin.Building a chrooted sshBy design, OpenSSH does not include the capacity to be chrooted, as the developers contend such functionality belongs in the OS. Luckily, a third party patch has been developed. The patch, a pre-patched openssh tarball, and a good document about setting up the chrooted sftp are available at http://chrootssh.sourceforge.net/. Download the tarball for openssh, and the chrootssh patch. Untar the openssh sources, then apply the patch. [urbana@bubbles ssh]$ tar xzf openssh-3.6.1p2.tar.gz[urbana@bubbles ssh]$ cd openssh-3.6.1p2[urbana@bubbles openssh-3.6.1p2]$ patch -p1 < ../osshChroot-3.6.1.diffpatching file session.cNow build the chroooted OpenSSH. [urbana@bubbles openssh-3.6.1p2]$ ./configure --with-md5-password[urbana@bubbles openssh-3.6.1p2]$ makeBefore you make install, you may want to make a copy of your current ssh binaries, if they are installed in /usr/local/bin and /usr/local/sbin, which is where openssh will put them by default. The install will not overwrite your config files or host keys, though if you're paranoid like us you'll back them up anyway. [root@bubbles openssh-3.6.1p2]# make installThis goes swimmingly on my Red Hat 7.3 workstation. Now, you'll need to kill the old sshd and start the new one. In my case, I have been running sshd from a different location, /usr/sbin/sshd which is where Red Hat installs it. In order to keep the rc script working, either change the path to sshd in your sshd rc script, (/etc/rc.d/init.d/sshd or something like that) or create a link like so: [root@bubbles openssh-3.6.1p2]# mv /usr/sbin/sshd /usr/sbin/sshd.old[root@bubbles openssh-3.6.1p2]# ln -s /usr/local/sbin/sshd /usr/sbin/sshd[root@bubbles ssh]# service sshd stopStopping sshd: [ OK ][root@bubbles ssh]# service sshd startStarting sshd: [ OK ]Make sure you can ssh to your machine from another box. If sshd is working, we can proceed to my favorite part, setting up the chrooted jail. Building a Jail The chrooted environment must contain everything a user needs to copy files back and forth using sftp. This includes utilities used by sftp, libraries, a home directory, and even some device files. This will keep the user safely off the rest of the system. Before you get too excited, keep in mind that chrooted jails can be broken. But not easily. Referring to the document at chrootssh.sourceforge.net, we'll build our jail. We're going to call ours alcatraz. [root@bubbles u01]# mkdir alcatraz[root@bubbles alcatraz]# mkdir bin dev home lib usr[root@bubbles alcatraz]# cd binCopying the necessary binaries: [root@bubbles bin]# cp /

来源:http://www.tulaoshi.com/n/20160129/1506071.html

延伸阅读
    linux简介: 最初萌发发明设计Linux操作系统念头的是一位来自芬兰的年轻人 Linus B. Torvalds, 他对MINIX系统十分熟悉. 开始 Linus B. Torvalds 并没有发行这套新操作系统的二进制文件, 只是对外散布源代码而已. 如果想要编译源代码, 还需要MINIX的编译程序才行. 起初 Linus Torvalds 想要将这套新系统命名为freax. ...
提升 Linux 开发者的能力为您的 Linux 应用开发加油提速:在 Power 上使用 Linux 开放源代码工具http://www-900.cn.ibm.com/developerWorks/cn/linux/linux-speed-start/l-ss3p-open/index.shtmlhttp://www-900.cn.ibm.com/developerWorks/cn/linux/linux-speed-start/l-ss3p-open/index.shtml
标签: 服务器
linux学习笔记之linux文件管理 内容: #文件系统及Shell的基本概念 #文件及目录操作命令 #VI的使用 #软件包的管理 一、文件系统及Shell的基本概念 1.文件系统的含义 文件系统是用来管理和组织保存在磁盘驱动器上数据的系统软件 2.Linux的文件系统 Linux系统采用虚拟文件系统技术(VFS)、结构采用倒立树型、VFS使Linux支持以下...
  第十一章 核心机制 本章主要描叙Linux核心为使核心其他部分能有效工作而提供的几个常用任务与机制。 11.1 底层部分处理机制 图11.1 底层部分处理机制数据结构 某些特殊时刻我们并不愿意在核心中执行一些操作。例如中断处理过程中。当中断发生时处理器将停止当前的工作, 操作系统将中断发送到相应的设备驱动上去...
  第十五章 Linux核心数据结构 本章列出了Linux实用的主要数据结构。 block_dev_struct 此结构用于向核心登记块设备,它还被buffer cache实用。所有此类结构都位于blk_dev数组中。 struct blk_dev_struct { void (*request_fn)(void); struct request * current_request; struct reque...

经验教程

135

收藏

97

精华推荐

Linux 网管 123 --- 第3章. 概观 Linux

Linux 网管 123 --- 第3章. 概观 Linux

莫小陌殃

Linux 核心--15.Linux内核资源

Linux 核心--15.Linux内核资源

超级青春纪念册

Linux学习基础

Linux学习基础

可爱的天痕

微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部