Linux系统通过密钥ssh登陆配置方法

一、制作密钥对

1.打开windows或者Mac OS中的powershell,输入

#生成密钥对
ssh-keygen -t RSA -b 2048 -C "your@domain.com"
#-t 后表示ssh的密钥类型,常用的有:rsa、ed25519、dss
#-C 后表示名称标识
#-b 为指定密钥长度,默认2048

2.随后要求指定密钥保存位置,要求输入密码,可为空。最后出现密钥保存位置等信息。

二、上传公钥

将公钥上传至远程主机,放至/root/.ssh文件夹下authorized_keys文件中。
此时通过powershell进行ssh登陆显示Permission denied (publickey).

三、修改配置文件

先使用如下命令,测试状态:

ssh -vv root@ip -p port

发现powershell无法使用改名后的私钥,因此修改配置文件。
Mac OS 内置了keychain管理各种密钥,可以通过如下命令增加所管理的密钥。

##mac系统添加需验证的密钥
ssh-add -K [密钥所在的path]
#windows系统指定密钥
ssh -i path root@server

附:ssh命令合集

ssh: illegal option -- h
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
           [-i identity_file] [-J [user@]host[:port]] [-L address]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-Q query_option] [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] destination [command]

ssh软件推荐:Windterm
下载地址

© 版权声明
THE END
喜欢就发表一下看法吧
点赞1 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容