查看OpenSSH版本
linux系統(tǒng)一般自帶OpenSSH
:~$ ssh -V
安裝ssh
sudo apt-get install openssh-client
sudo apt-get install openssh-server
啟動(dòng)ssh服務(wù)
systemctl start sshd.service
查看ssh服務(wù)狀態(tài)
/etc/init.d/ssh status
常用啟動(dòng)/關(guān)閉服務(wù)命令
systemctl start sshd.service 或者 service sshd start //啟動(dòng)SSH服務(wù)
systemctl stop sshd.service 或者 service sshd stop //關(guān)閉SSH服務(wù)比然。
systemctl restart sshd.service 或者 service sshd restart //重啟SSH服務(wù)
systemctl enable sshd.service 或者 service sshd enable //設(shè)置服務(wù)開機(jī)自啟
遠(yuǎn)程連接服務(wù)器
ssh命令截碴,user是服務(wù)器用戶状植,host是服務(wù)器ip
$ ssh user@host (可以在config中配置甫题,使用 ssh 別名杆麸,不需要用戶名和主機(jī)ip. config)
$ ssh host 如果本地用戶名與遠(yuǎn)程用戶名一致闯估,登錄時(shí)可以省略用戶名
ssh免密登陸配置
- 本地生成密鑰(默認(rèn)路徑)
ssh-keygen -t rsa
- 配置到遠(yuǎn)程服務(wù)器
ssh-copy-id [-i [identity_file]] [user@]machine寞宫,配置時(shí)需要輸入密碼
#ssh-copy-id [-i [identity_file]] [user@]machine
#ssh-copy-id [-h|-?|-f|-n] [-i [identity_file]] [-p port] [[-o <ssh -o options>] ...] [user@]hostname
ssh-copy-id -i /home/opsy/.ssh/id_rsa.pub root@47.114.46.42