目录

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 connect
ssh -X userName@[hostname|IP] #Support GUI
ssh 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 host
scp -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远程连接的更多相关文章

  1. MSSQL远程连接

    背景:部署公司自己研发的ERP系统. 1)系统架构: .NET+MSSQL. 2)服务器系统:Windows Server 2008 R2 Enterprise 3)数据库:MSSQL Server ...

  2. 配置mysql允许远程连接的方法

    默认情况下,mysql只允许本地登录,如果要开启远程连接,则需要修改/etc/mysql/my.conf文件. 一.修改/etc/mysql/my.conf找到bind-address = 127.0 ...

  3. Windows操作系统下远程连接MySQL数据库

    用Eclipse做一个后台项目,但是数据库不想放在本地电脑,于是买了一个腾讯云服务器(学生有优惠,挺便宜的),装上MySQL数据库,但是测试连接的时候,发现总是连接不是上,但是本地数据库可以连接,于是 ...

  4. Windows远程连接Linux

    目录 xrdp方式 vnc方式 xrdp方式 ----------------------------------------------------------------------------- ...

  5. MYSQL远程登录权限设置 ,可以让Navicat远程连接服务器的数据库

    Mysql默认关闭远程登录权限,如下操作允许用户在任意地点登录: 1. 进入mysql,GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ...

  6. SQL Server 2008 允许远程连接的配置

    如果无法通过IP地址远程连接你的SQL Server 2008服务器,可以参考下面的内容进行设置.在进行下述设置之前,应该确保你的网络已经安装设置完毕,服务器已经正常连接到网络中. 1.单击Windo ...

  7. 【先定一个小目标】怎么解决mysql不允许远程连接的错误

    最近使用Navicat for MySQl访问远程mysql数据库,出现报错,显示“1130 - Host'xxx.xxx.xxx.xxx' is not allowed to connect to ...

  8. access基本操作(c#操作,远程连接,执行sql,加密,备份)

    前言 最近项目用到了access,是的就是access,工作在桌面型的小数据库应用还是会用到的,如果你确定永远不会遇到access的操作,请忽略此篇文章 1.vs配置access 既然是数据库,就少不 ...

  9. mongodb安装、启动、远程连接

    1.现在mongodb安装包 mongodb-linux-x86_64-3.0.6.tgz 2.解压缩安装包 tar zxvf  mongodb-linux-x86_64-3.0.6.tgz /opt ...

随机推荐

  1. js 元素offset,client , scroll 三大系列总结

    1,element.offsetWidth : 包括 padding 和 边框 2,element.clientWidth : 包括 padding ,不包含边框 , 内容超出会溢出盒子的时候,就用s ...

  2. vue 简介 vue 项目 组件

    1. 概念 Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架.能够为复杂的单页应用提供驱动. 2. 用法 2.1 声明式渲染 2.1.1 改变文本     {{ m ...

  3. 85. Maximal Rectangle (JAVA)

    Given n non-negative integers representing the histogram's bar height where the width of each bar is ...

  4. pycharm解释器链接如何pymongo

    1.pymongo 链接数据库 # pycharm 链接我们的mogodb # 下载pymongo from pymongo import MongoClient # 客户端请求 服务端 # 链接 c ...

  5. python socket使用

    自学python,先在菜鸟教程网自学,然后买了本书看.又从同事那里淘到了某个培训学校python教学视频,查缺补漏.视频是用python3.0讲的,讲解的很不错,中间有让写作业,这个我很喜欢.这几天看 ...

  6. (转) Java中的负数及基本类型的转型详解

    (转) https://my.oschina.net/joymufeng/blog/139952 面这行代码的输出是什么? 下面两行代码的输出相同吗? 请尝试在Eclipse中运行上面的两个代码片段, ...

  7. Directed Roads CodeForces - 711D (基环外向树 )

    ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it co ...

  8. Codeforces 982 树边两端点计数偶数连通块 鲨鱼活动最小K最大location 扩展欧几里得方块内光线反射

    A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_bac ...

  9. 【串线篇】SpringBoot数据访问【数据源/mybatis/指定映射文件位置】

    一.配置数据源 1.1.jdbc版本 JDBC(.tomcat.jdbc.pool.DataSource作为数据源) <?xml version="1.0" encoding ...

  10. java 死锁演示

    java 死锁演示 java死锁 模拟死锁生成 死锁是由多个线程竞争同一个资源导致 package com.feshfans; /** * 1. 本代码为展示 java 中死锁的产生 * 2. 死锁的 ...