歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux管理 >> Linux服務 >> 通過SecureCRT制作SSH連接鏈接Linux服務器的公私密鑰

通過SecureCRT制作SSH連接鏈接Linux服務器的公私密鑰

日期:2017/2/28 16:05:01   编辑:Linux服務

一、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 ]

Copyright © Linux教程網 All Rights Reserved