Skip to content

Instantly share code, notes, and snippets.

@mpasternacki
Created October 21, 2011 11:59
Show Gist options
  • Save mpasternacki/1303659 to your computer and use it in GitHub Desktop.
Save mpasternacki/1303659 to your computer and use it in GitHub Desktop.
Make Chef's `knife ssh` use your actual login name
# knife.rb config snippet to make knife ssh command use your own login
# instead of hard-coded `root', `ubuntu' or other name. Tries to get
# login for your domain from ~/.ssh/config and if it's not found
# there, uses your local login.
require 'net/ssh'
require 'etc'
knife[:ssh_user] =
Net::SSH::Config.for('some.host.inside.your.domain')[:user] ||
Etc.getlogin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment