大网数据广告活动
服务器运维问答

openssh - Adding an ssh key from putty to authorized_keys

· 52CE 我爱测

I have been provided with an ssh key by a colleague to add to the authorized_keys file for an account on a linux server so they can access that account. The file looks something like this: ---- BEGIN SSH2 PUBLIC KEY ---- Comment:…

问题原文

原帖链接 · Michael Slade · CC BY-SA 3.0

I have been provided with an ssh key by a colleague to add to the authorized_keys file for an account on a linux server so they can access that account.

The file looks something like this:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20160816"
AAAAB3NzaC1yc2EAAAABJQAAAQEApoYJFnGDNis/2oCT6/h9Lzz2y0BVHLv8joXM
s4SYcYUVwBxNzqJsDWbikBn/h32AC36qAW24Bft+suGMtJGS3oSX53qR7ozsXs/D
lCO5FzRxi4JodStiYaz/pPK24WFOb4sLXr758tz2u+ZP2lfDfzn9nLxregZvO9m+
zpToLCWlXrzjZxDesJOcfh/eszU9KUKXfXn6Jsey7ej8TYqB2DgYCfv8jGm+oLVe
UOLEl7fxzjgcDdiLaXbqq7dFoOsHUABBV6kaXyE9LmkbXZB9lQ==
---- END SSH2 PUBLIC KEY ----

The man page for authorized_keys (well, sshd) makes it clear that the file expects each key to take up a single line. So I guess I need to convert this key to a single-line format? How do I accomplish this?

已采纳解答

原帖链接 · Matt Watson · CC BY-SA 4.0

There is an accepted answer for this question, but I think it's worth noting that there is a way to do this using the ssh-keygen tool rather than sed:

ssh-keygen -i -f ssh2.pub > openssh.pub

Where ssh2.pub is your existing ssh2 key and openssh.pub will be the key in openssh format. If you just want to copy and paste you can leave out the redirect and use:

ssh-keygen -i -f ssh2.pub

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。