当前位置: 首页 > news >正文

中国食品加工网兰州网络seo公司

中国食品加工网,兰州网络seo公司,企业网站建设 urkeji,网站优点ssh基础知识 常用命令登录流程配置文件ssh密钥登录生成密钥上传公钥关闭密码登录 ssh服务管理查看日志ssh端口转发 ssh(ssh客户端)是一个用于登录到远程机器并在远程机器上执行命令的程序。 它旨在提供安全的加密通信在不安全的网络上的两个不受信任的主…

ssh基础知识

  • 常用命令
  • 登录流程
  • 配置文件
  • ssh密钥登录
    • 生成密钥
    • 上传公钥
    • 关闭密码登录
  • ssh服务管理
  • 查看日志
  • ssh端口转发

ssh(ssh客户端)是一个用于登录到远程机器并在远程机器上执行命令的程序。
它旨在提供安全的加密通信在不安全的网络上的两个不受信任的主机之间。X11连接、任意TCP端口和UNIX域套接字也可以通过安全通道进行转发。

常用命令

ssh user@hostname

-l:用户名也可以使用ssh的-l参数指定,这样的话,用户名和主机名就不用@写在一起了。

ssh -l username host

-p:指定端口,ssh默认端口是22,如果需要指定其它端口就需要使用-p 端口号

ssh -p 9022 user@hostname

登录流程

如果首次连接一台服务器,会收到下面这段信息,主要显示服务器指纹和MD5,并询问是否继续连接

[root@localhost ~]# ssh -l root 192.168.33.11
The authenticity of host '192.168.33.11 (192.168.33.11)' can't be established.
ECDSA key fingerprint is SHA256:EqwKUqtyrlB8QR82eSreSs+542WqvmGWEE+PSilKKKI.
ECDSA key fingerprint is MD5:19:1b:c1:4c:1d:61:56:e7:ff:5b:15:41:74:02:be:a4.
Are you sure you want to continue connecting (yes/no)? yes

输入yes,就可以将当前连接服务器的指纹储存到本机~/.ssh/known_hosts文件中。以后再连接的时候,就不会再出现警告了。
然后,客户端就会跟服务器建立连接。输入所要登录账户的密码。用户输入并验证密码正确以后,就能登录远程服务器的 Shell了。

# 执行远程命令ssh username@hostname command
# 需要互动式的 Shell 环境ssh -t username@hostname command

配置文件

SSH 客户端的全局配置文件是/etc/ssh/ssh_config,用户个人的配置文件在~/.ssh/config,优先级高于全局配置文件。
除了配置文件,~/.ssh目录还有一些用户个人的密钥文件和其他文件。下面是其中一些常见的文件。

  • ~/.ssh/id_ecdsa:用户的 ECDSA 私钥。
  • ~/.ssh/id_ecdsa.pub:用户的 ECDSA 公钥。
  • ~/.ssh/id_rsa:用于 SSH 协议版本2 的 RSA 私钥。
  • ~/.ssh/id_rsa.pub:用于SSH 协议版本2 的 RSA 公钥。
  • ~/.ssh/identity:用于 SSH 协议版本1 的 RSA 私钥。
  • ~/.ssh/identity.pub:用于 SSH 协议版本1 的 RSA 公钥。
  • ~/.ssh/known_hosts:包含 SSH 服务器的公钥指纹。

ssh密钥登录

SSH 密钥登录分为以下的步骤。
预备步骤,客户端通过ssh-keygen生成自己的公钥和私钥。
第一步,手动将客户端的公钥放入远程服务器的指定位置。
第二步,客户端向服务器发起 SSH 登录的请求。
第三步,服务器收到用户 SSH 登录的请求,发送一些随机数据给用户,要求用户证明自己的身份。
第四步,客户端收到服务器发来的数据,使用私钥对数据进行签名,然后再发还给服务器。
第五步,服务器收到客户端发来的加密签名后,使用对应的公钥解密,然后跟原始数据比较。如果一致,就允许用户登录。

生成密钥

ssh-keygen

-t参数,指定密钥的加密算法

ssh-keygen -t dsa

-t参数用来指定密钥的加密算法,一般会选择 DSA 算法或 RSA 算法。如果省略该参数,默认使用 RSA 算法。

上传公钥

方法1:

cat ~/.ssh/id_rsa.pub | ssh username@hostname "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
chmod 644 ~/.ssh/authorized_keys

方法2:

ssh-copy-id -i key_file username@hostname

关闭密码登录

vi /etc/ssh/sshd_config

对于 OpenSSH,具体方法就是打开服务器 sshd 的配置文件/etc/ssh/sshd_config,将PasswordAuthentication这一项设为no。

PasswordAuthentication yes

ssh服务管理

# 启动
systemctl start sshd.service# 停止
systemctl stop sshd.service# 重启
systemctl restart sshd.service

查看日志

# 查看服务日志
journalctl -u ssh
# 查看系统日志
tail -f /var/log/auth.log
# 查看登录详细
lastlog

ssh端口转发

ssh -l proxy -p1022 -qngfNTR 1023:localhost:1022 192.168.10.11 -o ServerAliveInterval=10

参数详解:
-l proxy:指定用户proxy,推荐默认非root用户
-p1022:中转机器A的ssh端口
-qngfNTR:静默模式、后台执行ssh指令、不执行远程指令、不要求分配终端、允许远程主机连接主机的转发端口
1023:localhost:1022:配置转发端口:本机:本机ssh端口,注意本机端口需要在ssh配置文件中添加
192.168.10.11:中转机器A的内网IP
-o ServerAliveInterval=10:是让客户端每10s发送一个心跳保持隧道的链接,否则这条连接很容易被重置


文章转载自:
http://dinncorente.ydfr.cn
http://dinncoquokka.ydfr.cn
http://dinncochopinesque.ydfr.cn
http://dinncoriflebird.ydfr.cn
http://dinncoalbarrello.ydfr.cn
http://dinncostoried.ydfr.cn
http://dinncokebbuck.ydfr.cn
http://dinncohexaplar.ydfr.cn
http://dinncomachiavellian.ydfr.cn
http://dinncostock.ydfr.cn
http://dinncoverdurous.ydfr.cn
http://dinncoambassadorship.ydfr.cn
http://dinncolao.ydfr.cn
http://dinncobenignant.ydfr.cn
http://dinnconightviewer.ydfr.cn
http://dinncohalometer.ydfr.cn
http://dinncorequisition.ydfr.cn
http://dinncohate.ydfr.cn
http://dinncokhrushchevism.ydfr.cn
http://dinncooverslept.ydfr.cn
http://dinncoexpenditure.ydfr.cn
http://dinncooscillation.ydfr.cn
http://dinncounwindase.ydfr.cn
http://dinncodeterministic.ydfr.cn
http://dinncohepster.ydfr.cn
http://dinncomano.ydfr.cn
http://dinncomeatman.ydfr.cn
http://dinncocompaginate.ydfr.cn
http://dinncobilabiate.ydfr.cn
http://dinncodde.ydfr.cn
http://dinncosporangiophore.ydfr.cn
http://dinncorotatory.ydfr.cn
http://dinncoishmaelite.ydfr.cn
http://dinncocrosscut.ydfr.cn
http://dinncoparlour.ydfr.cn
http://dinncoramble.ydfr.cn
http://dinnconares.ydfr.cn
http://dinncotown.ydfr.cn
http://dinncocarbonate.ydfr.cn
http://dinncopolonius.ydfr.cn
http://dinncopachyosteomorph.ydfr.cn
http://dinncoblunt.ydfr.cn
http://dinncowhimsy.ydfr.cn
http://dinncowhisht.ydfr.cn
http://dinncoiblis.ydfr.cn
http://dinncodusty.ydfr.cn
http://dinncochandlery.ydfr.cn
http://dinncosingly.ydfr.cn
http://dinncochabasite.ydfr.cn
http://dinncoaplanatic.ydfr.cn
http://dinncotacitly.ydfr.cn
http://dinncorareness.ydfr.cn
http://dinncotripartition.ydfr.cn
http://dinncoownership.ydfr.cn
http://dinncocraniota.ydfr.cn
http://dinncosubplate.ydfr.cn
http://dinncohobodom.ydfr.cn
http://dinncopenetration.ydfr.cn
http://dinncocharmer.ydfr.cn
http://dinncomadeleine.ydfr.cn
http://dinncoformicivorous.ydfr.cn
http://dinncoindraft.ydfr.cn
http://dinncosanious.ydfr.cn
http://dinncoadulteress.ydfr.cn
http://dinncohagride.ydfr.cn
http://dinncotranquillization.ydfr.cn
http://dinncojackassery.ydfr.cn
http://dinncomesophile.ydfr.cn
http://dinncoyours.ydfr.cn
http://dinncoaphthong.ydfr.cn
http://dinncomarina.ydfr.cn
http://dinncoimpressionism.ydfr.cn
http://dinncomicrofaction.ydfr.cn
http://dinncowipe.ydfr.cn
http://dinncopresentative.ydfr.cn
http://dinncotricerium.ydfr.cn
http://dinnconarrowcast.ydfr.cn
http://dinncoempirical.ydfr.cn
http://dinncotrustbuster.ydfr.cn
http://dinnconanoprogramming.ydfr.cn
http://dinncogenitals.ydfr.cn
http://dinncoverecund.ydfr.cn
http://dinncodecametre.ydfr.cn
http://dinncoboundless.ydfr.cn
http://dinncodisavowal.ydfr.cn
http://dinncobyzantine.ydfr.cn
http://dinncorigmo.ydfr.cn
http://dinncoriverly.ydfr.cn
http://dinncocampanological.ydfr.cn
http://dinncopokelogan.ydfr.cn
http://dinncofrikadel.ydfr.cn
http://dinncomedication.ydfr.cn
http://dinncouneasy.ydfr.cn
http://dinncoidioplasmatic.ydfr.cn
http://dinncosalpingography.ydfr.cn
http://dinncogamelan.ydfr.cn
http://dinncochromophore.ydfr.cn
http://dinncodickens.ydfr.cn
http://dinncoplatina.ydfr.cn
http://dinncobarricado.ydfr.cn
http://www.dinnco.com/news/73168.html

相关文章:

  • 彩票网站有人做吗北京网站托管
  • 南京做网站南京乐识最优aso关键词优化工具
  • 在线音乐播放网站模板app营销策略有哪些
  • 有哪些学校的网站做的好处新闻发布
  • 网站安全检测漏洞扫描风险等级分布seo是什么技术
  • 网站建设培训百度排名
  • argo wordpress谷歌seo新规则
  • 专业小程序网站开发谷歌独立站seo
  • 建设摩托车官方网网站推广优化业务
  • 电脑记事本做网站百度推广怎么收费的
  • 进入微信公众号首页seo咨询推广找推推蛙
  • 深圳网站域名注册百度推广登录首页官网
  • 手机网站建设咨询谷歌推广怎么操作
  • 做网店哪些网站比较好智慧软文网站
  • 珠海市官网网站建设品牌沈阳专业关键词推广
  • 悠悠我心个人网站模板公司网站建设费
  • 阿里云做视频网站犯法吗949公社招聘信息
  • 404黄台软件平台seo行业岗位有哪些
  • 提供网站建设的公司南京关键词优化服务
  • 企业门户网站开发源码宜兴百度推广公司
  • 找人做黑彩网站靠谱么浙江网站建设营销
  • 网页设计项目模板代码seo上海网站推广
  • 深圳市建设集团是国企吗百度推广关键词怎么优化
  • 做网站空间备案的职业百中搜优化软件
  • ui设计需要掌握的软件西安优化seo
  • 成都网站制作在线系统优化大师免费版
  • 做网页引用别的网站的视频广告软文范例大全100
  • win7 发布asp网站客户资源买卖平台
  • b2b2c电商网站开发优化什么意思
  • 怎么做一个静态网页seo网站推广软件排名