2017-09-01 70 views
0

我想通过ssh从一个用户/客户端组合(例如,[email protected])访问用户/服务器组合(例如,[email protected]),其中两个不同类型的访问:从给定用户1 /客户端到同一用户2 /服务器的多个ssh访问类型

  1. 访问类型#1将被限制为与bazaar存储库的交互。 对于这一点,我在~user2/.ssh/authorized_keys添加了一行(#1)像

    command="bzr serve --inet --directory=/repodir --allow-writes",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-rsa ... [email protected] 
    
  2. 访问类型#2将是一个登录shell。 对于这一点,我在~user2/.ssh/authorized_keys添加了一个“通常”的线路(#2)一样

    ssh-rsa ... [email protected] 
    

据我所知,并且如我测试,这两条线不能被同时使用。 也就是说,如果线#1中首先出现~user2/.ssh/authorized_keys,那么我将能够与BZR回购互动,但我不能做

[[email protected]]$ ssh [email protected] 

如果线#2首先出现在~user2/.ssh/authorized_keys,然后我就能够做到ssh,但任何bzr操作给

bzr: ERROR: Not a branch ... 

有没有什么办法来解决这一问题?

我使用的是RHEL7,但我想这不重要。

相关职位(但没有解决我的情况,我的理解):

Best way to use multiple SSH private keys on one client

https://serverfault.com/questions/142997/what-options-can-be-put-into-a-ssh-authorized-keys-file

https://serverfault.com/questions/749474/ssh-authorized-keys-command-option-multiple-commands

https://askubuntu.com/questions/1962/how-can-multiple-private-keys-be-used-with-ssh

回答

0

我做了工作,有两个不同的密钥对(比如,对于bzr和pai,配对1 r 2为ssh登录)。 我在~user2/.ssh/authorized_keys中添加了相应的行。 私钥1存储在文件id_rsa(默认读取) 中,私钥2存储在文件id_rsa_ssh中。

然后,bzr被正常工作,以及用于在记录我使用

[[email protected]]$ ssh -i id_rsa_ssh [email protected] 
其指示使用替代身份

相关问题