美文网首页
服务器操作

服务器操作

作者: 依哥 | 来源:发表于2016-11-08 13:38 被阅读0次

marager

  • ssh root@115.28.19.199 连接marager或者web服务器
  • vi /etc/hostname marager 或者web 设置服务器名
  • reboot 重启服务器
  • 10.174.228.145 通过局域网也可以连接

生成秘钥

  • ssh-keygen -t rsa 生成秘钥 路径:/root/.ssh/id_rsa
G33G7PAM)YYD$LIYEQVIL}W.png
  • vi /etc/hosts 修改hosts文件如下(修改局域ip别名)

![]AE1RMQC)LR9UC1A5F%_U}S.png](https://img.haomeiwen.com/i2916990/5d49a7d36d671452.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![F]AVPOCAQBG]_C~OI`7HQE7.png](https://img.haomeiwen.com/i2916990/f20352e9107d1c10.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

SCP命令

  • scp ./id_rsa.pub root@FWEB1:/root === scp ./id_rsa.pub root@121.42.202.209:/root 将公钥文件传到web1服务器中
  • 默认没有.ssh目录,所以新建mkdir .ssh,将id_rsa.pub文件导入到~/.ssh/authorized_keys 。使用命令如下:

cat id_rsa.pub >> .ssh/authorized_keys

  • 修改 'authorized_keys' 权限

chmod 600 authorized_keys

为了保证服务器安全,我们将密码登录关闭

找到 etc/ssh/sshd_config 修改 PasswordAuthentication yes (如果有注释将#去掉,将yes改为no )

修改端口 : Port 1678(重启reboot 或 然后需要更新下sshd的配置:sudo systemctl reload sshd)
要使用 -p 选项,后面在加上 SSH 端口号。
ssh 192.168.0.103 -p 1234

IPtables

123

alias 别名

  1. vim .bash_profile
  • alias FWEB1='ssh root@FWEB1 -p 1678'
  • 重新加载source.bash_profile文件
  • source .bash_profile

相关文章

网友评论

      本文标题:服务器操作

      本文链接:https://www.haomeiwen.com/subject/jkmauttx.html