一、windows下安装好secureCRT6.2
二、root用户登入linux服务器
增加用户:useradd -m username
设置密码:passwd username
将username加入root,wheel组:gpasswd -a username root
gpasswd -a username wheel
设置好secureCRT连接的hostname,username
三、密钥制作
记住不要upload
四、上传生成的 Identity.pub至服务器该用户名的home/username下
公钥的上传及设置
a.上传公钥(默认的后缀名为.pub).一般是用ftp上传.注意上传之前,一定要以ASCII格式上传.
b.服务器端的设置.首先要在要登录的用户home目录下建一个.ssh目录.
cp /home/houliangzhou/Identity.pub/home/houliangzhou/.ssh/
chmod 755 /home/houliangzhou/.ssh
ssh-keygen -i -f Identity.pub >>authorized_keys
chmod 644 authorized_keys
五、修改sshd_config文件
vi /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $
# This is the sshd server system-wideconfiguration file. See
# sshd_config(5) for more information.
# This sshd was compiled withPATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in thedefault sshd_config shipped with
# OpenSSH is to specify options with theirdefault value where
# possible, but leave them commented. Uncommented options change a
# default value.
#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#RSAAuthentication yes
PubkeyAuthentication yes #打开允许采用密钥方式远程登录
AuthorizedKeysFile .ssh/authorized_keys #打开
# For this to work you will also need hostkeys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust~/.ssh/known_hosts for
#RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't readthe user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords,change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication no #关闭密码验证
AllowUsers root shaobingliusong houliangzhou lizhi zws #设置允许密码登录的账户
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
六、修改保存之后重启sshd服务
~]# servicesshd restart #重启sshd服务
Stopping sshd: [ OK ]
Starting sshd: [ OK ]