https://blog.51cto.com/u_13438667/2117175
https://www.cnblogs.com/ftl1012/p/ssh.html
-
安装openssh服务器 (一般如果ssh连不上,就得安装)
sudo apt install openssh-server
-
~/.ssh目录下文件说明
https://blog.csdn.net/catoop/article/details/119350507
https://www.jb51.net/article/94599.htmauthorized_keys:ssh免密登录相关
known_hosts:每一个连接过的服务器的ip及公钥会记录在此。
当使用~/.ssh/config里的别名连接gerrit,会报错:Permission denied (publickey).
-
ssh密钥对生成
ssh-keygen -t rsa -C "管理员" -f ~/.ssh/zhchen
-t:指定加密类型,一般采用rsa。
-f:密钥文件名
-C:为公钥添加注释(大写C) -
ssh调试信息打印
ssh -v,-v参数即会打印详细的调试信息。 -
ssh免密登录
https://blog.csdn.net/tyustli/article/details/122222605
https://blog.csdn.net/goodparty/article/details/127532042
https://blog.csdn.net/hengge113/article/details/126371510
ssh -i key root@192.168.0.32
windows上可能会报:Permissions for 'xxx' are too open.
或者Permission denied (publickey)
错误,解决办法(chmod 600 密匙名.pem
):https://blog.csdn.net/weixin_44806146/article/details/129260136 (只保留当前用户的所有权限) ,如果当前用户是admin用户,则执行命令打开cmd也要使用用户权限打开。
Host key verification failed
:https://blog.csdn.net/ouyang_peng/article/details/83115290 执行ssh-keygen -R hostname
即解决。
- root用户登录
https://blog.csdn.net/m0_56051805/article/details/125649828
vim /etc/ssh/sshd_config
,增加PermitRootLogin yes,然后重启ssh服务。service sshd restart
scp上传与下载文件
https://blog.csdn.net/tyustli/article/details/122453051
- 上传:
scp -P 22 .\test.md tyustli@192.168.10.18:/home/tyustli/temp // -P 22 参数可选
scp上传文件夹报错:not a regular file:加上-r参数
- 下载:
scp -P 22 tyustli@192.168.10.18:/home/tyustli/temp/make/makefile ./ // -P 22 参数可选
ssh服务无法启动的问题排查
通过/usr/sbin/sshd -T
会返回ssh无法启动的原因
- 情况一:sshd: no hostkeys available -- exiting.
执行ssh-keygen -A
之后重启ssh即可
0 条评论