配置ssh免密登录
程序员文章站
2024-02-23 18:05:58
...
win上的ssh也是在~/.ssh目录。
文章目录
生成ssh**
参考
Note:过程中使用phase是有必要的。否则的话会生成相同的id_rsa.pub
ssh-****** -t rsa
ssh config
code ~/.ssh/config
如下图配置。配置了好了之后可以直接
ssh ubuntu
进行登录。
Host ubuntu
User kyle
HostName 192.168.1.105
Port 2222
设置ssh免密登录
ssh-copy-id [email protected]
说明:
ssh-copy-id 使用的前提是client, 已经有了.ssh以及在其内的非对称加密的公钥和私钥。如果没有的话,参考具体原理介绍中的做法。
可能会出现ssh-copy-id成功【成功是指将客户端的公钥~/.ssh/id_rsa.pub
中的公钥拷贝到服务器~/.ssh/authorized_keys
中】。但是无法免密登录的情况。检查/home/kyle
文件的权限是不是755
, 即drwxr-xr-x
。如果不是 sudo chmod 0755 /home/kyle
。 是的,不用使用-R
参数。 所以直接将id_rsa.pub中的内容拷贝到authorized_keys也是可以实现免密登录的。
登出ssh
exit
SETTING UP PUBLIC KEY AUTHENTICATION FOR SSH
The following simple steps are required to set up public key authentication (for SSH):
Key pair is created (typically by the user). This is typically done with ssh-******.
Private key stays with the user (and only there), while the public key is sent to the server. Typically with the ssh-copy-id utility.
Server stores the public key (and marks it as authorized).
Server will now allow access to anyone who can prove they have the corresponding private key.
上一篇: linux grep命令详解
下一篇: c#日志记录帮助类分享