一、Secure CRT密钥登录配置
生成步骤:
工具->
创建公钥(密钥类型:RSA;通行短语:登录密码[可不输入,不输入时登录无需密码,只要密钥匹配即可],密钥长度1024或者2048)->
生成2个文件(Identity和Identity.pub)
配置步骤:
将Identity.pub文件放到对应账号目录的.ssh目录下(比如/root/.ssh/或者/home/voip/.ssh/)
在账号目录下执行#ssh-keygen -i -f .ssh/Identity.pub>>.ssh/authorized_keys(/root/或者/home/voip/)
在Secure CRT中新建连接,并选择【属性】->【连接】->【SSH2】->【身份验证】->【公钥】,选中【公钥】->【属性】,注意需要去除【身份验证】中的【口令】及【键盘交互】等选项。
选中【使用会话公钥设置】选项,并选择【使用身份或证书文件】的文件,确定后在SSH2的会话选项主界面配置主机名、端口、用户名等信息;
重启Linux服务端的sshd(命令service sshd restart)服务即可使用密钥登录。
注意:
不同的指纹(MD5)需要使用不同的Identity和Identity.pub文件!!!
linux下使用公钥文件登录:
chmod -R 600 test.pem #pem公钥文件必须为600权限,否则可能被拒绝
ssh [email protected] -i test.pem
问题:sudo -i执行后报错"voip is not in the sudoers file. This incident will be reported."
因为voip不在/etc/sudoers文件中,所以voip被禁止sudo切换权限
解决办法:
root权限下chmod 600 /etc/sudoers,然后修改/etc/sudoers文件
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
voip ALL=(ALL) ALL #添加voip到root后面
改完/etc/sudoers文件后,记得chmod 440 /etc/sudoers,否则存在root权限漏洞
例如:
voip ALL=(root) NOPASSWD: /usr/sbin/tcpdump #给voip账号开启tcpdump权限(使用命令#sudo tcpdump port 5060)
二、如何通过私钥获取公钥
生成步骤:
工具->
创建公钥(密钥类型:RSA;通行短语:登录密码[可不输入,不输入时登录无需密码,只要密钥匹配即可],密钥长度1024或者2048)->
生成2个文件(Identity和Identity.pub)
配置步骤:
将Identity.pub文件放到对应账号目录的.ssh目录下(比如/root/.ssh/或者/home/voip/.ssh/)
在账号目录下执行#ssh-keygen -i -f .ssh/Identity.pub>>.ssh/authorized_keys(/root/或者/home/voip/)
在Secure CRT中新建连接,并选择【属性】->【连接】->【SSH2】->【身份验证】->【公钥】,选中【公钥】->【属性】,注意需要去除【身份验证】中的【口令】及【键盘交互】等选项。
选中【使用会话公钥设置】选项,并选择【使用身份或证书文件】的文件,确定后在SSH2的会话选项主界面配置主机名、端口、用户名等信息;
重启Linux服务端的sshd(命令service sshd restart)服务即可使用密钥登录。
注意:
不同的指纹(MD5)需要使用不同的Identity和Identity.pub文件!!!
linux下使用公钥文件登录:
chmod -R 600 test.pem #pem公钥文件必须为600权限,否则可能被拒绝
ssh [email protected] -i test.pem
问题:sudo -i执行后报错"voip is not in the sudoers file. This incident will be reported."
因为voip不在/etc/sudoers文件中,所以voip被禁止sudo切换权限
解决办法:
root权限下chmod 600 /etc/sudoers,然后修改/etc/sudoers文件
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
voip ALL=(ALL) ALL #添加voip到root后面
改完/etc/sudoers文件后,记得chmod 440 /etc/sudoers,否则存在root权限漏洞
例如:
voip ALL=(root) NOPASSWD: /usr/sbin/tcpdump #给voip账号开启tcpdump权限(使用命令#sudo tcpdump port 5060)
二、如何通过私钥获取公钥
ssh-keygen -y -f private.pem #输出即为private.pem的公钥,可能需要输入密钥原语(需要保证private.pem权限为600)
要想成为一个出色的程序员,请前往IT搜123 www.itso123.com了解,搜集各种程序员必备网站。