找回密码
 立即注册
搜索
查看: 214|回复: 3

请教一个关于ssh2得问题

[复制链接]

49

主题

511

回帖

734

积分

高级会员

积分
734
发表于 2003-4-27 23:58:53 | 显示全部楼层 |阅读模式
在一台服务器(Solaris8)上开了一个ssh的服务,现在我可以实现在一台终端上通过SecureCRT的Password验证方式,登陆此服务器;但是我现在想用它的PublicKey的验证方式来登陆此服务器,我看了半天帮助没有看明白。特此来问一下大家,看看有没有知道的,请指点一下。谢谢!!

327

主题

3264

回帖

3641

积分

荣誉版主

积分
3641
发表于 2003-4-28 09:35:04 | 显示全部楼层
应该是不可以的,publickey是散发给大家的,但是拥有privateKey的才可以连进来,我的看法。

呵呵,想问个问题,我在linux上,ssh服务就是起不来,我在setup中把ssh勾上了,但是reboot后没用,请问,ssh应该怎么配呢?有什么详细的步骤说明吗?先谢谢了!
回复

使用道具 举报

49

主题

511

回帖

734

积分

高级会员

积分
734
 楼主| 发表于 2003-4-28 12:40:22 | 显示全部楼层
最初由 厨师 发布
[B]应该是不可以的,publickey是散发给大家的,但是拥有privateKey的才可以连进来,我的看法。

呵呵,想问个问题,我在linux上,ssh服务就是起不来,我在setup中把ssh勾上了,但是reboot后没用,请问,ssh应该怎么配呢?有什么详细的步骤说明吗?先谢谢了! [/B]


安装步骤是在网上找到的,我就是按照这个步骤做的。
--------------------------------------------------------------------------------

Installing OpenSSH Packages for SPARC and Intel/Solaris 8

--------------------------------------------------------------------------------

Openssh is meant to supply security to your systems. If you don't understand how to properly use it, you may have problems. Such problems are your responsibility. See our disclaimer. Please read the instructions below fully and carefully before you do any installation.

Installation of the openssh software on a Solaris machine is lengthy, but straightforward. To get ssh and sshd running you need to install a number of packages. There are a number of places on the net with details of this procedure. One of the best is on the Sun Blueprints web pages (in pdf format) at

Building and Deploying OpenSSH on Solaris[tm] Operating System (a pdf file)

or the

The OpenSSH Home Page

I do not use the Sun blueprint method exactly because some things have changed since that document was created.

Openssh requires that each machine have some sort of random (really pseudo- ) number generation. Solaris 8 does not come with /dev/random and /dev/urandom built-in, but patches have been released to correct this. If you do not want to install these patches and you want to build your own packages, I have supplied the prngd software that was used previously.

The seven pieces of software that may need to be on your system to use ssh properly are openssl, openssh, zlib, libgcc (if you have gcc 3.2.2 installed you don't need this), and optionally egd, prngd, perl, and tcp_wrappers. You can either download the sources and do the compiles yourself if you have a C compiler installed and working or you can go to sunfreeware.com and get pre-compiled packages. If you are very concerned about your machine's security and don't want to trust software compiled by someone else, then it is best for you to compile the software yourself. It is also a great learning experience.

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/ openssh
http://www.openssh.org/ openssl
http://www.lothar.com/tech/crypto/ egd
ftp://ftp.porcupine.org/pub/security/index.html tcp_wrappers

I have included support for the optional use of the tcp_wrappers program (using the so-called Advanced Method). This can help to restrict the use of ssh logins to those computers defined in the so-called hosts.allow and hosts.deny files when set up properly. Ssh logins can also be logged using this software.



--------------------------------------------------------------------------------

Installation Steps

--------------------------------------------------------------------------------

Step Zero: Getting the random patches for Solaris 8

You CANNOT skip this step. This version of openssh requires that the /dev/random patches be installed. If you are running a system where rebooting to have the patch apply cannot be done, then it is possible to do with without rebooting. One example of how to do this can be found at

http://www.sunmanagers.org/piper ... 2-April/002956.html

To obtain the patches, go to


SunSolve Patch Access

To find the SPARC/Solaris 8 patch 112438-01, type 112438-01 into the Enter a PatchID search window and click the Find Patch button. This will take you to the page where the patch is described and where the patch download links are. Download the patch and install it as indicated in the instructions. You will probably need to reboot your system to have the patch apply. Rebooting requires boot -r to create the new devices.

For the Intel/Solaris 8 patch look for 112439-01 instead and follow the same instructions. There are a number of posts in newsgroups on the net about these patches. Go to Google Groups and search for patch 112438-01 or 112439-01 and you will find a number of discussions that may be of help.

Step One: Getting the packages

To install the version of openssh from sunfreeware.com, go to the main page and select the files for SPARC/Solaris 8 at the right.

Or, here are the files you need to download for SPARC:

openssh-3.6.1p1-sol8-sparc-local.gz
openssl-0.9.7a-sol8-sparc-local.gz
tcp_wrappers-7.6-sol8-sparc-local.gz (optional, but recommended)
(unless you are using IPV6 - see the tcp_wrappers listing for details on this issue)
zlib-1.1.4-sol8-sparc-local.gz
libgcc-3.2.2.2-sol8-sparc-local.gz
perl-5.8.0-sol8-sparc-local.gz (optional)
prngd-0.9.25-sol8-sparc-local.gz (optional)
egd-0.8-sol8-sparc-local.gz (optional)

or for Intel:

openssh-3.6.1p1-sol8-intel-local.gz
openssl-0.9.7a-sol8-intel-local.gz
tcp_wrappers-7.6-sol8-intel-local.gz (optional, but recommended)
(unless you are using IPV6 - see the tcp_wrappers listing for details on this issue)
zlib-1.1.4-sol8-intel-local.gz
libgcc-3.2.2.2-sol8-intel-local.gz
perl-5.8.0-sol8-intel-local.gz (optional)
prngd-0.9.25-sol8-intel-local.gz (optional)
egd-0.8-sol8-intel-local.gz (optional)

If you have already installed some of the above files, you can skip their downloads, but most are new.


Step Two: Installing the packages

With the files downloaded, go to the directory where you put them and run (with the Intel files replacing the SPARC files for the Intel packages):

# gunzip openssh-3.6.1p1-sol8-sparc-local.gz

# gunzip openssl-0.9.7a-sol8-sparc-local.gz

# gunzip zlib-1.1.4-sol8-sparc-local.gz

# gunzip libgcc-3.2.2-sol8-sparc-local.gz  (if you don't already have gcc 3.2.2 installed)

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

and optionally for the other packages.  Then run as root

# pkgadd -d openssh-3.6.1p1-sol8-sparc-local

# pkgadd -d openssl-0.9.7a-sol8-sparc-local

# pkgadd -d zlib-1.1.4-sol8-sparc-local

# pkgadd -d libgcc-3.2.2-sol8-sparc-local (if you don't already have gcc 3.2.2 installed)

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

Once you have installed the packages above, you will have files in various subdirectories of /usr/local. The default location for the ssl files is in /usr/local/ssl. While these files were compiled to avoid the need to put directories like /usr/local/lib and /usr/local/ssl/lib in your LD_LIBRARY_PATH, it is possible that you may need to set this. You should now find ssh in /usr/local/bin and sshd in /usr/local/sbin. Make sure you have /usr/local/bin and /usr/local/sbin in your PATH environment variable. The perl scripts in the optional egd package (with .pl extensions) will look for perl in /usr/local/bin. If you are using the Sun perl, then the Perl programs will need to have /usr/bin at the beginning, while the sunfreeware Perl goes in /usr/local/bin.

Step Three: Setting up the sshd user and the /var/empty directory

In openssh 3.6.1p1, a new security method is setup called privilege separation. The details can be found in the README.privsep file in the openssh source distribution. This method is now the default in openssh. Before doing anything else, you should read the above document and if you agree, implement these steps as root:


# 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/false sshd

/var/empty should not contain any files.

If you do not do this and attempt to start up sshd, you will get error messages and the daemon will not start.


Step Four: Setting up tcp_wrappers

The next step it to setup tcp_wrappers. First read the README.tcpwrappers so that you know what tcp_wrappers does and how. Basically, tcp_wrappers is used to restrict to some limited group of machines access to your communication ports such as the port 22 that the sshd program uses. If you have tcp_wrappers running already, then you will only need to make sure that the sshd daemon entry is placed in the /etc/hosts.allow and /etc/hosts.deny files in a way that is appropriate to your setup. If you are not currently running tcp_wrappers, you can first create the file /etc/hosts.deny and put the single line

sshd: ALL

in it. Then, create the file /etc/hosts.allow file and put a line, for example, like

sshd: ... a list of the IP numbers of machine you want to be able to communicate with your machine separated by commas ...

in the file. We will test these entries later.

Step Five: Installing ssh and sshd

This is the final step. You should have read the README.openssl and INSTALL.openssl documents and you should also have read the openssh documents README.openssh and INSTALL.openssh.

Each machine that you want to communicate with via the ssh client will need to have an sshd daemon running. But first, you need to run the following three lines to create the key information for the server machine. Again, make sure you have /usr/local/bin and /usr/local/sbin in your PATH. If you have been running sshd before and have keys in /usr/local/etc, runing these commands will overwrite them. As root, enter

# ssh-keygen -t rsa1 -f /usr/local/etc/ssh_host_key -N ""
# ssh-keygen -t dsa -f /usr/local/etc/ssh_host_dsa_key -N ""
# ssh-keygen -t rsa -f /usr/local/etc/ssh_host_rsa_key -N ""

and wait until each is done - this may take a few minutes depending on the speed of your machine.
You might also want to study the /usr/local/etc/ssh_config and /usr/local/etc/sshd_config files to see if there is anything you want to configure differently. The Sun version of ssh and sshd have configuration and key files in /etc/ssh which you may want to study also, though the packages here will not use them.

Now we can set up scripts to start the sshd daemon. I use the script which I call sshd and place in the /etc/init.d directory (as root): There have been some comments on the net recently in the sun-managers mailing list that this script should be replaced. See the post below for details.

#!/bin/sh

pid=`/usr/bin/ps -e | /usr/bin/grep sshd | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
case $1 in
'start')
        /usr/local/sbin/sshd
        ;;
'stop')
        if [ "${pid}" != "" ]
        then
                /usr/bin/kill ${pid}
        fi
        ;;
*)
        echo "usage: /etc/init.d/sshd {start|stop}"
        ;;
esac

Alternative Script Comment




Date: Mon, 13 Jan 2003 14:43:53 -0600 (CST)
From: "Mike's List"
To: [email protected]
Subject: SUMMARY: sshd weirdness

Lots of responses on this one, I used the basic script below (from Luc).
Most responded that the script for the sunfreeware.com is badly written
and that the error or non-existence PID is from the grep to kill sshd.
I'm no script expert, only reporting what others replied.

Some recommends search for the /var/run/sshd.pid, this way your ssh
terminal won't get zap while sshd daemon is re-hup or stop/start.

Thanks all.


- Mike


case "$1" in
'start')
        if [ -x /usr/local/sbin/sshd ]; then
                echo "Starting the secure shell daemon"
                /usr/local/sbin/sshd &
        fi
        ;;

'stop')
        echo "Stopping the secure shell daemon "
        pkill -TERM sshd
        ;;
*)
        echo "Usage: /etc/init.d/sshd { start | stop }"
        ;;
esac
exit 0


On Fri, 10 Jan 2003, Mike's List wrote:

> Ok, quite a few asked to see the script (below) --Solaris 8 2/02 running
> sunfreeware.com openssh 3.6.1p1 --a couple of suggestions below doing
>
> /bin/sh -x /etc/init.d/sshd stop
>
> ...to see what's going on, I'm in the server remotely right now so I can't
> stop/start (because stop would just kills all the sshd processes and I
> can't get back in to start).
>
>
> - Mike
>
>
> #!/bin/sh
> pid=`/usr/bin/ps -e | /usr/bin/grep sshd | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
> case $1 in
> 'start')
>         /usr/local/sbin/sshd
> ;;
> 'stop')
>         if [ "${pid}" != "" ]
>         then
>                 /usr/bin/kill ${pid}
>         fi
>         ;;
> *)
>         echo "usage: /etc/init.d/sshd {start|stop}"
>         ;;
> esac

End of Alternative Script Comment

I then do

# chown root /etc/init.d/sshd
# chgrp sys /etc/init.d/sshd
# chmod 555 /etc/init.d/sshd
# ln -s /etc/init.d/sshd /etc/rc2.d/S98sshd

# /etc/rc2.d/S98sshd start

will start the process if you want to do it by hand and

# /etc/rc2.d/S98sshd stop

will stop the sshd daemon. You can check this with

# ps -e | grep sshd

to see if sshd is running. If sshd is running and you have set up tcp_wrappers the way you want, then you can test the system. Of course, you have to have another machine that has the ssh program installed so that you can try to communicate with the machine on which you just started sshd. See the OpenSSH documentation for further details. To test that tcp_wrappers is working, you can put a machine's IP address in hosts.allow and see if you can ssh to the server machine from the client and then take it out and see if access is denied.
回复

使用道具 举报

327

主题

3264

回帖

3641

积分

荣誉版主

积分
3641
发表于 2003-4-28 23:30:01 | 显示全部楼层
多谢了,copy下来,以后试试,呵呵
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|海浩社区

GMT+8, 2025-9-21 15:05 , Processed in 0.089216 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表