SSH配置:覆盖默认用户名 [英] SSH configuration: override the default username

查看:459
本文介绍了SSH配置:覆盖默认用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以配置ssh知道我的用户名应该是什么?

Is it possible to configure ssh to know what my username should be?

默认情况下,它使用当前用户名,在我看来,这是不正确的.

By default it uses the current username, which is not correct in my case.

我在借贷者笔记本电脑上,我的用户名是loaner,但是我想告诉ssh我的用户名是buck.

I'm on a loaner laptop, and my username is loaner, but I want to tell ssh that my username is buck.

加分:我在家里的用户名是bgolemon.如果我可以配置每个主机的用户名,那就更好了.

Bonus points: my username at home is bgolemon. If I could configure the username per-host that would be even better.

推荐答案

~/.ssh内部创建一个名为config的文件.您可以在文件内添加:

Create a file called config inside ~/.ssh. Inside the file you can add:

Host *
    User buck

或添加

Host example
    HostName example.net
    User buck

第二个示例将设置一个用户名,并且特定于主机名,而第一个示例仅设置一个用户名.而且当您使用第二个时,您不需要使用ssh example.netssh example就足够了.

The second example will set a username and is hostname specific, while the first example sets a username only. And when you use the second one you don't need to use ssh example.net; ssh example will be enough.

这篇关于SSH配置:覆盖默认用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆