免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1776 | 回复: 9
打印 上一主题 下一主题

如何只允许1台Client可以以root身份登录V490 Server? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-07-11 18:12 |只看该作者 |倒序浏览
因为网络安全的需要,想只允许一台Client可以以root身份登录Server,同时禁止其他Client以root身份登录。如何可以作到,需要在/etc/default/login中定义吗?谢谢支持!

论坛徽章:
0
2 [报告]
发表于 2006-07-12 00:05 |只看该作者
用 ssh + tcpwrapper 可以做。

论坛徽章:
0
3 [报告]
发表于 2006-07-12 09:11 |只看该作者
原帖由 yangsmile 于 2006-7-11 18:12 发表
因为网络安全的需要,想只允许一台Client可以以root身份登录Server,同时禁止其他Client以root身份登录。如何可以作到,需要在/etc/default/login中定义吗?谢谢支持!


So far, I don't have any idea.

On the other hand, 因为网络安全的需要, root远程登录应完全禁止.

论坛徽章:
0
4 [报告]
发表于 2006-07-12 09:13 |只看该作者
原帖由 susbin 于 2006-7-12 00:05 发表
用 ssh + tcpwrapper 可以做。


tcpwrapper 不可以指定用户.

论坛徽章:
0
5 [报告]
发表于 2006-07-12 09:46 |只看该作者
Agree with chinaux -- root远程登录应完全禁止.
However, there's still a way to allow remote login of root user var ssh
from a client with a static IP. We can run two ssh2d. One on port 22 and
the other one on port 122.

论坛徽章:
0
6 [报告]
发表于 2006-07-12 10:09 |只看该作者
那请问可以应用于此情况的SSH在哪里可以下载?谢谢

论坛徽章:
0
7 [报告]
发表于 2006-07-12 15:28 |只看该作者
the s/w can be the same, but installed on different locations with different configuration, and will listen to different ports, .e.g. 22/tcp, 2222/tcp.

. disable root logon to 22/tcp.
. configure tcpwrapper for 2222/tcp so that ssh from a specific IP is allowed.

论坛徽章:
1
操作系统版块每日发帖之星
日期:2016-01-15 06:20:00
8 [报告]
发表于 2006-07-12 16:41 |只看该作者
solaris 9以上的版本已经自带了ssh,只要打开了其功能就行.
还有一种解决办法,就是用普通用户登录后 su - .这样也可以呀!!
如果有其他人知道你的root用户密码和一个普通用户的密码,还是可以进去root用户的环境的!

论坛徽章:
1
操作系统版块每日发帖之星
日期:2016-01-15 06:20:00
9 [报告]
发表于 2006-07-12 16:42 |只看该作者
这里有一个ssh的安装使用文档,可供参考
openssh4.1p1在sparc solaris9下的安装

所有软件均来自www.sunfreeware.com

1. 确认所需软件包

源包地址
The sources for these different programs are on sunfreeware.com or you can go to their home pages at

http://www.zlib.org zlib
http://www.perl.org perl
http://www.aet.tu-cottbus.de/per ... tfix_tls/prngd.html prngd
http://www.openssl.org openssl
http://www.openssh.org openssh
http://www.lothar.com/tech/crypto/ egd
ftp://ftp.porcupine.org/pub/security/index.html tcp_wrappers

从sunfreeware下载的安装包
openssh-4.1p1-sol9-sparc-local.gz
openssl-0.9.7g-sol9-sparc-local.gz
tcp_wrappers-7.6-sol9-sparc-local.gz (optional, but recommended)
(unless you are using IPV6 - see the tcp_wrappers listing for details on this issue)
zlib-1.2.1-sol9-sparc-local.gz
perl-5.8.5-sol9-sparc-local.gz (optional)
prngd-0.9.25-sol9-sparc-local.gz (optional)
egd-0.8-sol9-sparc-local.gz (optional)

2. 安装下载的软件包

With the files downloaded, go to the directory where you put them and run

# gunzip openssh-4.1p1-sol9-sparc-local.gz

# gunzip openssl-0.9.7g-sol9-sparc-local.gz

# gunzip zlib-1.2.2-sol9-sparc-local.gz

# gunzip libgcc-3.3-sol9-sparc-local.gz  (if you don't have gcc 3.3.2 installed)

# gunzip tcp_wrappers-7.6-sol9-sparc-local.gz (again optional)


and optionally for the other packages.  Then run as root

# pkgadd -d openssh-4.1p1-sol9-sparc-local

# pkgadd -d openssl-0.9.7g-sol9-sparc-local

# pkgadd -d zlib-1.2.2-sol9-sparc-local

# pkgadd -d libgcc-3.3-sol9-sparc-local  (if you don't have gcc 3.3.2 installed)

# pkgadd -d tcp_wrappers-7.6-sol9-sparc-local (optional)

可选的那些软件包也装了,安装过程同上

3. sshd用户的安全设定

# mkdir /var/empty
# chown root:sys /var/empty
# chmod 755 /var/empty
# groupadd sshd
# useradd -g sshd -c 'sshd privsep' -d /var/empty -s /bin/sh sshd

增加了一个系统用户sshd,预备来启动sshd进程,sshd用户的home目录为/var/empty只有root用户才有权限

4. sshd的系统启动关闭脚本的设置

solaris9 自带的sshd启动关闭脚本已经非常好了,只要略加改造即可使用新安装的openssh4.1p1

solaris9 自己的ssh目录分布如下

/etc/ssh         ;ssh 和sshd的配置文件以及密匙文件
/usr/lib/ssh     :sshd等server端程序文件
/usr/bin/ssh     :ssh等client端程序文件

openssh4.1p1的程序包安装以后的目录分布

/usr/local/etc   : ssh 和sshd的配置文件以及密匙文件
/usr/local/sbin  : sshd等server端程序文件
/usr/local/bin   : ssh等client端程序文件

根据上面的分析即可将原有的sshd文件改造成如下

#!/sbin/sh
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
# ident "@(#)sshd       1.1     01/09/19 SMI"
#
# If sshd is configured (/etc/ssh/sshd_config exists and is readable),
# the start it up.
# Checks to see if RSA, and DSA host keys are available
# if any of these keys are not present, the respective keys are created.

KEYDIR=/usr/local/etc                       #将以前的/etc/ssh 修改为/usr/local/etc
KEYGEN="/usr/local/bin/ssh-keygen -q"       #将以前的/usr/bin/修改为/usr/local/bin
PIDFILE=/var/run/sshd.pid

case $1 in
'start')
        if [ -x /usr/local/bin/ssh-keygen ]; then             # 将以前的/usr/bin/修改为/usr/local/bin
                if [ ! -f "$KEYDIR/ssh_host_rsa_key" ]; then
                        echo "Creating new RSA public/private host key pair"
                        $KEYGEN -f $KEYDIR/ssh_host_rsa_key -t rsa -N ''
                fi

                if [ ! -f "$KEYDIR/ssh_host_dsa_key" ]; then
                        echo "Creating new DSA public/private host key pair"
                        $KEYGEN -f $KEYDIR/ssh_host_dsa_key -t dsa -N ''
                fi     
        fi

        [ -x /usr/local/sbin/sshd ] && /usr/local/sbin/sshd &       #将以前的/usr/lib/ssh/修改为/usr/local/sbin
        ;;
'stop')
        #
        # If we are switching Run level downwards then we disconnect
        # all connections.
        #
        # Otherwise we just kill the master daemon that is listening
        # and leave the connections active
        if [ -z "$_INIT_RUN_LEVEL" ]; then
                set -- `/usr/bin/who -r`
                _INIT_RUN_LEVEL="$7"
                _INIT_PREV_LEVEL="$9"
        fi
        
        if [ $_INIT_RUN_LEVEL -lt $_INIT_PREV_LEVEL ]; then
                /usr/bin/pkill -u 0 -x sshd
        fi
        if [ -f "$PIDFILE" ]; then
                /usr/bin/kill -TERM `/usr/bin/cat $PIDFILE`
        fi
        ;;

'restart')
        if [ -f "$PIDFILE" ]; then
                /usr/bin/kill -HUP `/usr/bin/cat $PIDFILE`
        fi
        ;;
*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac   

5. 原有的 ssh相关文件的善后处理工作

可以删除原有的sshd软件包,也可改名处理,这次是改名处理
# cd /usr/bin
# mv ssh-add ssh-add.old
# ln -s /usr/local/bin/ssh-add ssh-add
# mv ssh-agent ssh-agent.old
# mv ssh-keygen ssh-keygen.old
# ln -s /usr/local/bin/ssh-agent ssh-agent
# ln -s /usr/local/bin/ssh-keygen ssh-keygen     
# ln -s /usr/local/bin/ssh-keyscan ssh-keyscan
# mv /usr/bin/sftp /usr/bin/sftp.od
# ln -s /usr/local/bin/sftp /usr/bin/sftp

sshd文件是通过sshd脚本的来启动的,所以没有改动。

可能openssh4.1p1的编译成安装包默认就认为sshd_config和ssh_config文件就在/usr/local/etc,所以以前的/etc/ssh文件也没有改名,只是
再也用不到了。

6. tcp_wrappers 的设置工作

其实就是设置/etc/hosts.allow和/etc/hosts.deny,文件格式如下:
sshd: ALL

规则:如果hosts.allow和hosts.deny存在,只有在hosts.allow里面的条目才能登陆。

改了一下/etc/ssh/sshd_config
AllowTcpForwarding yes   //把原来no改为yes
PermitRootLogin yes     //把原来no改为yes

7. 启用新的openssh4.1p1

kill -9 杀掉 老的进程,/etc/init.d/sshd start开始新的sshd进程

8. 主要参考了http://www.sunfreeware.com/openssh9.html

论坛徽章:
0
10 [报告]
发表于 2006-07-12 21:17 |只看该作者
原帖由 chinaux 于 2006-7-12 15:28 发表
the s/w can be the same, but installed on different locations with different configuration, and will listen to different ports, .e.g. 22/tcp, 2222/tcp.

. disable root logon to 22/tcp.
. configu ...


正解。chinaux 不负其名。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP