ubuntu ssh 登录日志_ssh私钥生成与远程登陆

271150f5-9127-49ef-840c-e3860130445c

本地机器生成私钥公钥:

foo@ubuntu:~$ ssh-keygen -t rsa -b 4096Generating public/private rsa key pair.Enter file in which to save the key (/home/foo/.ssh/id_rsa): /home/foo/id_rsa_temp Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /home/foo/id_temp.Your public key has been saved in /home/foo/id_temp.pub.The key fingerprint is:SHA256:3PC/Q2m4eOi8ax0BhASvDS5PdwI/HYPaLhUocT97Xqc foo@ubuntuThe key's randomart image is:+---[RSA 4096]----+| . oo.o. || o +... || . + * +. || o O * *. || . = X S +o.. || + + * .o++ || o . .+E=. || . .+ + .. || o=+ .. |+----[SHA256]-----+

公钥写入目标机器的~/.ssh/authorized_keys文件。

 foo@ubuntu:~$ scp id_temp.pub too@192.168.1.7:/home/too/.ssh/authorized_keystoo@192.168.1.7's password:id_temp.pub 100% 736 794.2KB/s 00:00 

本地机器添加私钥,登录目标机器:

 foo@ubuntu:~/.ssh$ ssh-add id_tempIdentity added: id_temp (foo@ubuntu)foo@ubuntu:~/.ssh$ ssh too@192.168.1.7Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 4.4.0-31-generic i686) * Documentation: https://help.ubuntu.com/ System information as of Tue Aug 13 16:26:23 CST 2019 System load: 0.0 Processes: 167 Usage of /: 10.4% of 17.34GB Users logged in: 1 Memory usage: 3% IP address for eth0: 192.168.1.7 Swap usage: 0% Graph this data and manage this system at: https://landscape.canonical.com/24 packages can be updated.10 updates are security updates.Your Hardware Enablement Stack (HWE) is supported until April 2019.Last login: Tue Aug 13 14:48:54 2019 from too-all-seriestoo@192:~$ exitlogoutConnection to 192.168.1.7 closed.foo@ubuntu:~/.ssh$

上面把私钥写入.ssh中是因为ubuntu系统会在用户登录时自动添加.ssh中的私钥,这样方便未来登录远程机器。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值