# Rancher-cli login 2 clusters automatic

**URL:** <https://forums.suse.com/t/rancher-cli-login-2-clusters-automatic/10811>\
**Category:** SUSE Rancher Prime\
**Created:** [June 18, 2018, 12:32pm UTC](https://forums.suse.com/t/rancher-cli-login-2-clusters-automatic/10811 "2018-06-18T12:32:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![delck](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@delck](https://forums.suse.com/u/delck)\
**Post date:** [June 18, 2018, 12:32pm UTC](https://forums.suse.com/t/rancher-cli-login-2-clusters-automatic/10811/1 "2018-06-18T12:32:57Z")

</div>

Hi,

I want to use the rancher cli in our CI/CD-pipeline. We are using bamboo.

When only one cluster is managed by the Rancher everything works fine.

But when a second cluster is managed, the Cli is asking for a default cluster.

I tried

> " echo -e ‘yes\n1’ | rancher login --token … "  
> " printf-e ‘yes\n1’ | rancher login --token … "  
> " printf-e ‘yes\n1\n’ | rancher login --token … "

The result is always:

> Select your default Project:time=“2018-06-18T10:30:54+02:00” level=fatal msg=EOF

Ho can i set automatically on cluster? Is there a trick?

It would be great, when someone has an idea.

Greatings  
Delck

---

<div class="post-metadata">

**Author:** ![Josh\_H](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@Josh\_H](https://forums.suse.com/u/Josh_H)\
**Post date:** [July 18, 2018, 4:01am UTC](https://forums.suse.com/t/rancher-cli-login-2-clusters-automatic/10811/2 "2018-07-18T04:01:08Z")

</div>

Also having the same problem preventing us automating rancher deployments, making things really hard.

Anyone ?

---

<div class="post-metadata">

**Author:** ![damlub](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/damlub/32/4309_2.png) [@damlub](https://forums.suse.com/u/damlub)\
**Post date:** [February 4, 2019, 10:36am UTC](https://forums.suse.com/t/rancher-cli-login-2-clusters-automatic/10811/3 "2019-02-04T10:36:59Z")

</div>

In recent versions of rancher-cli you can specify --context. You can see available context-id when doing a manual login, it is called normally like “local:p-8ss68” or “c-5tq98:p-9lmbq”. Using local: works since rancher-cli-v2.2.0-rc5.  
Example:  
rancher login -t abcdef:ghijklmnopqrstuvwxzy --context c-5tq98:p-9lmbq [https://rancher.example.com](https://rancher.example.com)
