SSH端口:22
Linux中守护进程:sshd
安装服务:openssh
服务端主进程:/usr/sbin/sshd
客户端主进程:/usr/bin/ssh
服务端配置文件:/etc/ssh/sshd_config
客户端配置文件:/etc/ssh/ssh_config
非对称加密算法:公开密钥(publickey)和私有密钥(privatekey)
/etc/ssh/sshd_config
Port 22 端口
ListenAddress 0.0.0.0 监听的IP
Protocol 2 SSH版本选择
HostKey /etc/ssh/ssh_host_ras_key 私钥保存位置
ServerKeyBits 2048 私钥位数
SyslogFacility AUTH 日志记录SSH登录情况
LogLevel INFO 日志等级
GSSAPIAuthentication yes GSSAPI认证开启(DNS验证:IP-域名,登录缓慢)
-------------安全设定
PermitRootLogin yes 允许root的ssh登录
Pubkey Authentication yes 是否使用公钥验证
AuthorizedKeysFile .ssh/authorized_keys 公钥的保存位置
PasswordAuthentication yes 允许使用密码验证登录
PermitEmptyPasswords no 不允许空密码登录
SSH远程管理:
ssh username@IP
scp root@IP:/root/test.txt . 下载
scp -r(dir) test.txt root@IP:/root 上传
Sftp 文件传输(ssh 加密安全)
ls 查看服务器端数据
cd 切换服务器端目录
lls 查看本地数据
lcd 切换本地目录
get 下载
put 上传
sftp> help 帮助
密钥对登录:
Client:
ssh-keygen -t rsa(算法)
id_rsa(私钥) id_rsa.pub(公钥) know_hosts(已连接对方公钥)
Server: 把公钥上传到服务器端:
cat id_rsa.pub >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
-
RSAAuthentication yes 开启RSA验证
-
Pubkey Authentication yes 是否使用公钥验证
-
AuthorizedKeysFile .ssh/authorized_keys 公钥保存位置
-
PasswordAuthentication no 禁止使用密码验证登录