Linux_OpenSSH远程连接
来源:互联网 发布:iface102考勤安装软件 编辑:程序博客网 时间:2024/06/03 18:14
目录
- 目录
- SSH server
- SSH服务属性
- SSH协议执行原理
- SSH连接方式
- ssh Commands
- scp commands
- sftp commands
- SSH在生产环境中的使用
- 系统间备份文件rsync
SSH server
Software:Openssh-server
Service:
1.ssh(Security Shell)
2.sftp-server(Security File Transfer Protocol)
Configure directory:/etc/ssh
SSH服务属性
ssh(Secure Shell)协议:加密远程传输协议
ServerEnd port: 22
ClientEnd port:> 1024
配置文件:/etc/ssh/sshd_config(Server)、/etc/ssh/ssh_config(Client)
ssh Server(被连接端)发送Server公钥 —-> ssh Client(发起连接):~/.ssh/known_hosts
SSH协议执行原理
Client将拥有的公钥发送给Server并于Server的私钥进行比对。
若一致:Server用Client公钥加密一个将来传输的密码,再将密码发给Client,Clinet用自己的私钥来解密得到传输密码,Client用传输密码对数据加密。
若不一致:则拒绝访问。
SSH连接方式
1.密码验证
2.密钥验证,实现步骤:
(1)Client(连接段)生成密钥对(公钥/私钥)
ssh-keygen
#Create KeyPair in /UserName/.ssh
(2)将公钥发送给Server(被连接端)
ssh-copy-id -i ~/.ssh/id_rsa.pub userName@[hostname|ip]
ssh Commands
ssh userName@[hostname|IP] #Remote connectssh -X userName@[hostname|IP] #Support GUIssh userName@[hostname|IP] [commands] #[commands]:Execute following commands.
使用-X选项,需要在服务器端的/etc/ssh/ssh_config文件中设置 ForwardX11 yes 或者 X11Forwad yes,以启用 X11 Forwarding。
scp commands
scp:Security copy
scp -r [file|dir] userName@hostname:dirUrl #Copy local [file|directory] into remote hostscp -r userName@hostname:dirUrl [file|dir] #Copy remote [file|firectory] into local host
sftp commands
sftp userName@[hostname|IP] #Entry security ftp via protocol of ssh
连接Sftp后可以使用下面指令进行上传和下载文件
get file #dowmload the file
put file #upload the file
SSH在生产环境中的使用
一般不允许远程连接到root:
在SSH Server配置:
vim /etc/ssh/sshd_config
PermitRootLogin no
重启SSH服务
systemctl restart sshd.service
拒绝别人用密码登陆:
在SSH Server配置:
vim /etc/ssh/sshd_config
PasswordAuthentication no
重启SSH服务
systemctl restart sshd.service
系统间备份文件rsync
基于SSH协议的同步备份指令rsync
指令格式: rsync -option fileName userName@[hostname|ip]:/directory
Example:
rsync -a /etc/ 192.168.0.2:/tmp
注意:
如果是/etc/ ,复制过去的是目录下面的内容
如果是/etc,复制过去的是目录和目录下面的内容
选项:
-a 归档
-v 显示过程
-r 子目录
-l 同步链接文件
-p 保留权限
-t 保留时间戳
-g 保留属组
-o 保留属主
- Linux_OpenSSH远程连接
- 远程连接
- 远程连接
- 远程连接
- 远程连接
- 远程连接
- 远程连接
- 远程连接
- 远程连接
- 远程连接
- 远程连接
- 远程连接及远程控制
- Mysql远程开启远程连接
- Ubuntu 远程连接 Linux远程连接
- 远程连接ORACLE
- 远程连接问题
- EVC远程设备连接
- sqlserver 远程连接数据源
- Mac中启动另一个程序并将窗口置于最前面
- 快速排序法
- Eclipse开发JAVA中如何Debug
- Javascript模块化编程(三):require.js的用法
- 如何在装上Snappy Ubuntu的树莓派上启动WiFi
- Linux_OpenSSH远程连接
- 在 Windows 中实现 Java 本地方法
- VS2015插件推荐
- python多行注释
- 编译CEF(2171分支)
- setShadowLayer参数说明
- 光线追踪第三章翻译(转载)
- <iOS>NavigationBar
- 黑马程序员——ios知识整理——category、block、protocol