SSH和ShadowSocks是如何防止中间人攻击的?

https引入CA的概念,目的就是防止中间人攻击。顺着这条路,想到SSH协议和ShadowSocks是如何防止中间人攻击的?上网查了一下SSH的知识,并梳理了SS的运行原理,这两个都有了答案。

SSH

虽然有著名的DH密钥交换算法,但SSH原理上不能抵御中间人攻击。然而实际上,SSH使用TOFU(参考 1)安全模型等同于做到了防中间人攻击。SSH的首次连接会下载服务端的公钥,用户确认后公钥将被保存并信任。下次访问时客户端将会核对服务端发来的公钥和本地保存的是否相同,不同就发出中间人攻击的警告拒绝连接,除非用户手动清除已保存的公钥。所以,如果首次连接没有中间人,之后的连接就无需担心中间人,因为中间人给出的公钥和服务端给出的公钥相同的可能性可以忽略。如果首次连接就有中间人攻击,那么恭喜你中奖了。

TOFU模型类似于使用Firefox浏览器访问自签https证书的网站,首次访问会提示风险,让用户确认亦或选择离开。如果用户确认了并添加网站证书到信任列表,之后的访问都不会再提示,连接也会被标识为安全的。

ShadowSocks

SS和SSH的解决方案又不一样,原因在于SS不需要交换通信密钥。SS服务器搭建好配置密钥后,客户端使用同一个密钥加密内容传输。无论中间人何时出现,(客户端和服务端之间)接收到的内容都是被加密过的,从这些内容反推出密钥的可能性很小。

从另外一个角度来看,SS安全的原因是它只是一个代理传输通道,而不是用户和服务器的通讯信道。用户的数据需要经过SS客户端、SS服务器两层转发才最终达到真实服务器。只要密钥没有泄露出去,SS能保证的是SS客户端到SS服务器的这段是安全。用户到SS客户端以及SS服务端到真实服务器的数据安全就不属于SS所能管控的范围。

就翻墙而言,SS加密(或者说混淆)方式是非常巧妙的,不容易被发觉和查封(不像https或者SSH能轻易根据特征识别出来),所以用起来爽歪歪~

参考

  1. https://en.wikipedia.org/wiki/Trust_on_first_use
  2. http://www.ruanyifeng.com/blog/2011/12/ssh_remote_login.html
  3. https://www.quora.com/Is-SSH2-susceptible-to-an-active-man-in-the-middle-attack

2 thoughts on “SSH和ShadowSocks是如何防止中间人攻击的?

留言评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select * from vps_autoblog_queue where is_running >0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=6 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=6 and source_url_key='85f8e27ce55bd78fd33f47d2b1409198'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(6,'https://www.hijk.pw/post-sitemap.xml','85f8e27ce55bd78fd33f47d2b1409198',1750364702,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=4 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=4 and source_url_key='54b1dccf98c13c81f546faf82132bc77'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(4,'https://ssr.tools/sitemap-posttype-post.2020.xml','54b1dccf98c13c81f546faf82132bc77',1750364702,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=2 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=2 and source_url_key='91372ddcd9e4809b115feaa5b6f00815'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(2,'https://tlanyan.me/post-sitemap.xml','91372ddcd9e4809b115feaa5b6f00815',1750364702,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=7 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=7 and source_url_key='569e17863f7693f1afa9e9256af9dcff'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(7,'https://aisoa.cn/sitemap.xml','569e17863f7693f1afa9e9256af9dcff',1750364702,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=9 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=9 and source_url_key='cc9416f8df40d8c3a48e66856b1cd6fd'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(9,'https://www.v2rayssr.com/sitemap.xml','cc9416f8df40d8c3a48e66856b1cd6fd',1750364702,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=10 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=10 and source_url_key='74714f67855820f0c701ce905b231f27'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(10,'https://doubibackup.com/sitemap.xml','74714f67855820f0c701ce905b231f27',1750364702,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,is_running,last_post_time,post_interval,not_check_stoped from vps_autoblog_queue WHERE is_running>0 and fetched=0 order BY id ASC

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,sn_id from vps_autoblog_queue WHERE is_running=0 and fetched=0 order BY id ASC LIMIT 1