我似乎有一个奇怪的问题:
我想在启动时重新启动反向ssh隧道,我已经尝试使用init脚本(当以用户身份执行时效果很好)并在/etc/rc.d
中添加了一行,但没有任何效果。开机后我得到的是:
$ ps ax | grep autossh
397 pts/10 S+ 0:00 grep --color=auto autossh
1351 ? Ss 0:00 /usr/lib/autossh/autossh -M 22221 -N -o PubkeyAuthentication=yes -o PasswordAuthentication=no -i ~/.ssh/etherwan.key -R 19999:localhost:22 ubuntu@server
但是我无法从server
登录。所以我在启动后做了以下事情:
$ sudo killall -KILL autossh
[sudo] password for ron:
$ /usr/bin/autossh -M 22221 -f -N -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i ~/.ssh/etherwan.key -R 19999:localhost:22 ubuntu@server
我可以使用端口19999登录了!
密钥权限看起来像:(但是root不需要关心,对吗?)
$ ls -l ~/.ssh/etherwan.key
-r-------- 1 ron ron 1675 Nov 6 04:15 /home/ron/.ssh/etherwan.key
答案 0 :(得分:1)
在{em> rc.d 脚本中用~/.ssh/etherwan.key
/home/ron/.ssh/etherwan.key
shell将'〜'字符扩展到用户的主目录,但是 rc.d 脚本以root身份运行。