前端运维不得不学会的命令

发表于 2024-04-15
更新于 2024-05-23
分类于 技术专栏
阅读量 163
字数统计 2424

Docker相关

  • 上传文件到dev1:
1scp 本地文件名 username@servername:/path/filename
  • 下载文件到本地:(在本地电脑执行,如果是目录,加上 -r 即可)
1scp username@servername:/path/filename /var/www/local_dir
  • 进入Docker容器
1docker exec -it 容器名称 bash
  • 拷贝本地文件到Docker容器内部
1docker cp 本地文件名 容器名称:/home
  • 从容器内部拷贝到本地
1sudo docker cp 容器名称:/容器内文件路径 宿主机路径
  • 停止和删除容器
1docker stop 容器名称 && docker rm 容器名称
  • 启动容器
1docker run -dit --name 容器名称 -p 3000:3000 容器镜像存放的位置:1.0.1
  • 重启容器
1docker restart fe-node-linguang
  • 查看容器状态
1docker ps -a | grep 容器名称
  • 查看容器日志
1docker logs -f 容器名称

SSH相关

  • ssh 登录不上去的时候,有可能是config文件指定的失效了,可以通过强制指定秘钥来验证一下:
  ssh -i 秘钥文件 xx@xxx.com
  • 如果出现:Host key for github.com has changed and you have requested strict checking.Host key verification failed,示例如下:
1Cloning into 'doumi-blog'... 2@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ 4@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! 6Someone could be eavesdropping on you right now (man-in-the-middle attack)! 7It is also possible that a host key has just been changed. 8The fingerprint for the RSA key sent by the remote host is 9SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s. 10Please contact your system administrator. 11Add correct host key in /Users/linxiaowu/.ssh/known_hosts to get rid of this message. 12Offending RSA key in /Users/linxiaowu/.ssh/known_hosts:4 13Host key for github.com has changed and you have requested strict checking. 14Host key verification failed. 15fatal: Could not read from remote repository. 16 17Please make sure you have the correct access rights 18and the repository exists.

这个时候执行下面命令,即可修复:

1ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

公众号关注一波~

微信公众号

关于评论和留言

如果对本文 前端运维不得不学会的命令 的内容有疑问,请在下面的评论系统中留言,谢谢。

网站源码:linxiaowu66 · 豆米的博客

Follow:linxiaowu66 · Github