ssh技巧汇总

自动登录

简介

最近苦于linux下没有像SecureCRT这样便捷的虚拟终端软件,打算利用下这个ssh自动登录功能。流程说起来也简单,就是先把公钥和密钥分别保存到服务器和客户端,客户端登录只需要指定对应服务器的密钥就可以自动登录到服务器。

配置

这里只列举自动登录到多台服务器的配置过程,对于单台同样适用。

生成密钥
$ ssh-keygen  -t rsa
nter file in which to save the key \
(/home/lifeix/.ssh/id_rsa): /home/lifeix/.ssh/id_rsa_192.168.60.66
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/lifeix/.ssh/id_rsa_192.168.60.66.
Your public key has been saved in /home/lifeix/.ssh/id_rsa_192.168.60.66.pub
复制公钥到服务器

把.pub后缀的公钥文件scp到服务器,然后执行:

cat id_rsa_192.168.60.66.pub >> ~/.ssh/authorized_keys

建立alias别名

在.bashrc添加一行:

alias c1='ssh -i /home/lifeix/.ssh/id_rsa_192.168.60.66 root@192.168.60.66'

问题与解决办法

问题:按照上述设置,还是一直提示输入密码 解决办法:追踪log,在/var/log/secure下发现一条记录

Dec  9 15:12:17 n1 sshd[8908]: Authentication refused: \
bad ownership or modes for directory /home/skstsuperadmin/.ssh

所以chmod 755 .ssh就ok了。

2 Responses to “ssh技巧汇总”

  1. 博主最近过的怎么样啊

  2. 还好吧,挺忙挺累挺充实。

Leave a Reply