marager
-
ssh root@115.28.19.199連接marager或者web服務(wù)器 -
vi /etc/hostnamemarager 或者web 設(shè)置服務(wù)器名 -
reboot重啟服務(wù)器 -
10.174.228.145通過局域網(wǎng)也可以連接
生成秘鑰
-
ssh-keygen -t rsa生成秘鑰 路徑:/root/.ssh/id_rsa

G33G7PAM)YYD$LIYEQVIL}W.png
-
vi /etc/hosts修改hosts文件如下(修改局域ip別名)
![]AE1RMQC)LR9UC1A5F%_U}S.png](http://upload-images.jianshu.io/upload_images/2916990-5d49a7d36d671452.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![F]AVPOCAQBG]_C~OI`7HQE7.png](http://upload-images.jianshu.io/upload_images/2916990-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服務(wù)器中 - 默認(rèn)沒有
.ssh目錄,所以新建mkdir .ssh,將id_rsa.pub文件導(dǎo)入到~/.ssh/authorized_keys。使用命令如下:
cat id_rsa.pub >> .ssh/authorized_keys
- 修改 'authorized_keys' 權(quán)限
chmod 600 authorized_keys
為了保證服務(wù)器安全,我們將密碼登錄關(guān)閉
找到 etc/ssh/sshd_config 修改 PasswordAuthentication yes (如果有注釋將#去掉,將yes改為no )
修改端口 :
Port 1678(重啟reboot 或 然后需要更新下sshd的配置:sudo systemctl reload sshd)
要使用 -p 選項(xiàng),后面在加上 SSH 端口號(hào)。
ssh 192.168.0.103 -p 1234
IPtables
123
alias 別名
- vim .bash_profile
alias FWEB1='ssh root@FWEB1 -p 1678'- 重新加載source
.bash_profile文件 source .bash_profile