咸鱼

咸鱼是以盐腌渍后,晒干的鱼

0%

SSH公钥免密码登录

环境:

  1. 客户机Winows
  2. 服务器Linux (192.168.0.66)

操作

  1. 客户端公钥

一般安装了Git,本地都有ssh公钥,在目录 C:\Users\xxx\.ssh (即 ~/.ssh )下
如果没有,执行ssh-keygen生成。

  1. 上传公钥
1
2
$ ssh-copy-id -i  ~/.ssh/id_rsa.pub root@192.168.0.66
root的密码:
  1. 免密码登录

ssh登录

1
$ ssh root@192.168.0.66

scp拷贝文件

1
$ scp -r ./test/* root@192.168.0.66:/data/test

删除公钥

  1. 登录服务器
  2. vim ~/.ssh/authorized_keys
  3. 删除你的公钥

查看SSH登录日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# 显示近期用户或终端的登录情况,实际是查看 /var/log/wtmp 这个文件
$ last
root pts/0 192.168.0.30 Tue Oct 12 11:42 - 15:35 (03:53)
root pts/0 192.168.0.30 Mon Oct 11 14:32 - 14:33 (00:01)
root pts/0 192.168.0.30 Mon Oct 11 14:25 - 14:27 (00:02)

# 显示用户登录失败的列表,实际是查看 /var/log/btmp 这个文件
$ lastb
uftp ssh:notty 106.52.137.228 Sun Oct 3 13:55 - 13:55 (00:00)
uftp ssh:notty 106.52.137.228 Sun Oct 3 12:10 - 12:10 (00:00)
uftp ssh:notty 106.52.137.228 Sun Oct 3 12:10 - 12:10 (00:00)
ftp ssh:notty 106.52.137.228 Sun Oct 3 09:33 - 09:33 (00:00)
ftp ssh:notty 106.52.137.228 Sun Oct 3 09:33 - 09:33 (00:00)
nagios ssh:notty 106.52.137.228 Sun Oct 3 07:14 - 07:14 (00:00)
nagios ssh:notty 106.52.137.228 Sun Oct 3 07:14 - 07:14 (00:00)
mysql ssh:notty 106.52.137.228 Sun Oct 3 00:36 - 00:36 (00:00)
oracle ssh:notty 106.52.137.228 Sat Oct 2 23:27 - 23:27 (00:00)
oracle ssh:notty 106.52.137.228 Sat Oct 2 23:27 - 23:27 (00:00)
oracle ssh:notty 106.52.137.228 Sat Oct 2 22:17 - 22:17 (00:00)
oracle ssh:notty 106.52.137.228 Sat Oct 2 22:17 - 22:17 (00:00)
# 以上的记录是被攻击了???