环境:
- 客户机Winows
- 服务器Linux (192.168.0.66)
操作
- 客户端公钥
一般安装了Git,本地都有ssh公钥,在目录 C:\Users\xxx\.ssh
(即 ~/.ssh
)下
如果没有,执行ssh-keygen生成。
- 上传公钥
1 2
| $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.66 root的密码:
|
- 免密码登录
ssh登录
scp拷贝文件
1
| $ scp -r ./test/* root@192.168.0.66:/data/test
|
删除公钥
- 登录服务器
- vim ~/.ssh/authorized_keys
- 删除你的公钥
查看SSH登录日志
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
$ 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)
$ 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)
|