SSH工具

2020-03-18  本文已影响0人  诺之林

本文环境基于Ubuntu1604

目录

准备

sudo passwd
# 设置root密码

sudo adduser test
# 添加test用户

Client

命令

ssh-keygen -t rsa -C "test@test.com"
# /Users/kevin/.ssh/test

ssh-copy-id -i ~/.ssh/test.pub test@192.168.xx.xx

ssh test@192.168.xx.xx "ls -l ~/.ssh/"
# -rw------- 1 test test 395 Mar 18 17:02 authorized_keys

vim ~/.ssh/config
# Host 192.168.xx.xx
#   IdentityFile ~/.ssh/test

ssh test@192.168.xx.xx "cat ~/.ssh/authorized_keys" >> server.pub
cat ~/.ssh/test.pub >> local.pub
diff server.pub local.pub

文件

man ssh
This directory is the default location for all user-specific configuration and authentication information.

There is no general requirement to keep the entire contents of this directory secret,

but the recommended permissions are read/write/execute for the user, and not accessible by others.
Contains a list of host keys for all hosts the user has logged into that are not already in the systemwide list of known host keys.

This file should be writable only by root/the owner and can, but need not be, world-readable.
This is the per-user configuration file.

Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not writable by others.
Contains the private key for authentication.

These files contain sensitive data and should be readable by the user but not accessible by others (read/write/execute).
Contains the public key for authentication.

These files are not sensitive and can (but need not) be readable by anyone

Server

配置

dpkg -l | grep ssh
# openssh-server

sudo service --status-all | grep ssh
# [ + ]  ssh

sudo service ssh status
# Active: active (running)

同时设置ClientAliveInterval 10以及ClientAliveCountMax 0即10秒钟空闲超时断开连接

文件

man sshd
This directory is the default location for all user-specific configuration and authentication information.

There is no general requirement to keep the entire contents of this directory secret,

but the recommended permissions are read/write/execute for the user, and not accessible by others.
Lists the public keys (DSA, ECDSA, Ed25519, RSA) that can be used for logging in as this user.

The content of the file is not highly sensitive,

but the recommended permissions are read/write for the user, and not accessible by others.
上一篇 下一篇

猜你喜欢

热点阅读