我最近开始更换备份存储。带有WD MyBook的Mac Mini正在被Synology DiskStation取代。在将备份目标重定位到Synology之后,我一直用来同步我的外部硬盘与VM的备份脚本停止正常工作。该脚本基本上在每个文件的SSH会话中启动rsync进程。脚本的详细信息可以在这里找到; http://www.reddipped.com/2016/07/speeding-vm-backups-using-rsync/
为了能够在不必为每个SSH会话输入密码的情况下运行脚本,已配置了公钥认证。
ssh-keygen -t rsa -f ~/.ssh/id_rsa -C "rsync"
填写随机密码,例如" rsync协议"
将公钥复制到synology上的用户主目录
ssh Peter\ van\ Nes@newyork 'mkdir ~/.ssh'
cat ~/.ssh/id_rsa.pub | ssh Peter\ van\ Nes@newyork 'cat - >> ~/.ssh/authorized_keys'
ssh Peter\ van\ Nes@newyork 'chmod 644 .ssh/authorized_keys'
ssh Peter\ van\ Nes@newyork 'chmod 755 ~ ~/.ssh'
打开Synology的SSH会话
ssh "Peter van Nes"@newyork
编辑sshd_config
vi /etc/ssh/sshd_config
# Enable RSAAuthentication yes
# Enable PubkeyAuthentication yes
# Enable AuthorizedKeysFile .ssh/authorized_keys
# Enable ChallengeResponseAuthentication yes
# Add MaxSessions 50
# Add MaxStartups 50:10:100
重启服务
# restart ssh-shell
synoservicectl --restart ssh-shell
# restart rsync daemon
synoservicectl --restart rsyncd
完成这些步骤后,我可以成功使用公钥登录。运行脚本时,它最初按预期运行,只有在几千个文件之后才能再次输入密钥的密码。
我确实将问题分解为这个小脚本,为我重现了这个问题。
#!/bin/bash
sessions=0
while true
do
sessions=$(($sessions + 1))
echo "Session " $sessions
ssh peter@newyork -x "ls -al"
done
在几千个连续的SSH会话之后,再次请求公钥的密码。每次运行的顺序成功的会话数不同。这可以是2102但也是5000 +。
Session 2101
total 4
drwxr-xr-x 1 peter users 24 Oct 15 12:46 .
drwxrwxrwx+ 1 root root 92 Oct 16 22:29 ..
drwxr-xr-x 1 peter users 30 Oct 15 12:46 .ssh
-rwxrwxrwx+ 1 peter users 1239 Oct 15 12:46 .viminfo
Session 2102
total 4
drwxr-xr-x 1 peter users 24 Oct 15 12:46 .
drwxrwxrwx+ 1 root root 92 Oct 16 22:29 ..
drwxr-xr-x 1 peter users 30 Oct 15 12:46 .ssh
-rwxrwxrwx+ 1 peter users 1239 Oct 15 12:46 .viminfo
Session 2103
Enter passphrase for key '/Users/petervannes/.ssh/id_rsa':
使用-vvv参数运行ssh时不提供任何提示,Synology上的auth.log也会报告任何身份验证错误。
知道如何调试或修复此问题吗?
答案 0 :(得分:0)
通过使用let rect = CGRect(origin: CGPoint(x: 0, y:0), size: CGSize(width: 1, height: 1))
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()!
context.setFillColor(UIColor(red: 86.0/255.0, green: 200.0/255.0, blue: 246.0/255.0, alpha: 1.0).cgColor)
context.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
//To change Navigation Background colour.
navigationController?.navigationBar.setBackgroundImage(image, for: UIBarPosition.any, barMetrics: UIBarMetrics.default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.barTintColor = UIColor(red: 86.0/255.0, green: 200.0/255.0, blue: 246.0/255.0, alpha: 1.0)
//To change SearchBar Background colour.
self.searchBar.isTranslucent = false
self.searchBar.backgroundImage = image
searchBar.barTintColor = UIColor(red: 86.0/255.0, green: 200.0/255.0, blue: 246.0/255.0, alpha: 1.0)
searchBar.layer.borderColor = UIColor(red: 86.0/255.0, green: 200.0/255.0, blue: 246.0/255.0, alpha: 1.0).cgColor
将证书添加到钥匙串来修复它。
ssh-add -K