Ubuntu下修改SSH端口以及使用密匙登录

1.使用SecureCRT创建私钥和公钥.

SecureCRT: Quick Connect -> Authentiation -> Public Key -> Properties -> Create Identity File -> DSA/RSA -> Set Passphrase -> Done

这个时候在指定目录会生成两个文件,例如,私钥Identity和公钥Identity.pub

2.创建一个新用户

#useradd subsir -m#su subsir //切换到subsir用户,以下的操作必须用subsir账号操作,,subsir必须有权限

3.在/home/roger目录下创建.ssh文件夹并更改权限

# mkdir /home/subsir/.ssh# chmod 700 /home/subsir/.ssh

4.将公钥 Identity.pub 传到linux服务器,将SSH2兼容格式的公钥转换成为Openssh兼容格式

# ssh-keygen -i -f Identity.pub >> /home/subsir/.ssh/authorized_keys# chmod 600 /home/subsir/.ssh/authorized_keys

5.在SecureCRT里面设置登录模式为PublicKey,并选择刚刚创建的Identity文件作为私钥

6.重启Ubuntu服务器上SSH服务器

#sudo /etc/init.d/ssh restart

7.由于已经设置了密钥登录,原来的密码登录就完全可以去掉

# vi /etc/ssh/sshd_config

#假如要修改端口:#修改port 22 为 port 端口号

Protocol 2 /仅允许使用SSH2PubkeyAuthentication yes /*启用PublicKey认证PasswordAuthentication no /*禁止密码验证登录

我们一直在旅行,一直在等待某个人可以成为我们旅途的伴侣,

Ubuntu下修改SSH端口以及使用密匙登录

相关文章:

你感兴趣的文章:

标签云: