ssh远程登录笔记

资料

SSH原理与运用(一):远程登录

Generating a new SSH key and adding it to the ssh-agent

口令登录

ssh user@host

指定端口

ssh -p port user@host

公钥登录

生成公钥

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"


Generating public/private rsa key pair.

Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

Enter passphrase (empty for no passphrase): [Type a passphrase]

Enter same passphrase again: [Type passphrase again]

之后在 $HOME/.ssh/ 目录下,会新生成两个文件:id_rsa.pub 和 id_rsa, 前者是公钥,后者是私钥

复制公钥至服务器

ssh-copy-id user@host

指定端口

ssh-copy-id -p port user@host

之后ssh登录就不需要输入密码了。

如果无法登录,检查 /etc/ssh/sshd_config 文件中以下配置是否放开

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

重启 ssh 服务

service ssh restart
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值