# Some functions to make the below more readable
KEYGEN=/opt/openssh/bin/ssh-keygen
SSHD=/opt/openssh/sbin/sshd
RSA1_KEY=/opt/openssh/etc/ssh_host_key
RSA_KEY=/opt/openssh/etc/ssh_host_rsa_key
DSA_KEY=/opt/openssh/etc/ssh_host_dsa_key
PID_FILE=/opt/openssh/sshd.pid
do_restart_sanity_check()
{
$SSHD -t
RETVAL=$?
if [ ! "$RETVAL" = 0 ]; then
 failure $"Configuration file or keys are invalid"
 echo
fi
}
start()
{
# Create keys if necessary
do_rsa1_keygen
do_rsa_keygen
do_dsa_keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ourlinux/.ssh/id_rsa):
Created directory '/home/ourlinux/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ourlinux/.ssh/id_rsa.
Your public key has been saved in /home/ourlinux/.ssh/id_rsa.pub.
The key fingerprint is:
1a:00:46:93:bf:03:89:30:a5:a0:d5:c8:4f:25:f6:bc ourlinux@bixuan[/code:1]
6.测试连接
$ ssh -2 -p 222 IP
# 这里的-2表示用版本2,这里可以不用指定,以为已经是版本2了,只是为了说明的清楚点 -p 222表示连接端口是:222
The authenticity of host 'xxx.xxx.xxx.xx (xxx.xxx.xxx.xx)' can't be established.
RSA key fingerprint is 5e:39:69:5e:0b:56:23:63:b0:ce:5d:7c:37:e5:f5:28.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'xxx.xxx.xxx.xx' (RSA) to the list of known hosts.
Enter passphrase for key '/home/ourlinux/.ssh/id_rsa':
Last login: Mon Jan 10 03:35:06 2005 from xxx.xxx.xxx.xx