Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap fails: scp: command error: Control characters detected. (Net::SCP::Error) #8683

Open
kapilchouhan99 opened this issue Jun 24, 2019 · 2 comments

Comments

Projects
None yet
1 participant
@kapilchouhan99
Copy link
Contributor

commented Jun 24, 2019

Description

Created a windows 2012 r2 instance on google cloud and try to bootstrap it at that time we got an error: scp: command error: Control characters detected.

Chef Version

Chef Infra Client: 15.1.8

Platform Version

Windows 2012 r2

Replication Case

Please run this command:

knife bootstrap 13.71.2.45 -N azure-win -r "recipe[starter::default]" --connection-user 'user' --connection-password 'user@123456'  --connection-port 22 -c  ../chef-repo/.chef/knife.rb

Client Output

Traceback (most recent call last):
        28: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/bin/knife:23:in `<main>'
        27: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/bin/knife:23:in `load'
        26: from C:/D/git-repo/chef-repo/chef/bin/knife:24:in `<top (required)>'
        25: from C:/D/git-repo/chef-repo/chef/lib/chef/application/knife.rb:162:in `run'
        24: from C:/D/git-repo/chef-repo/chef/lib/chef/knife.rb:222:in `run'
        23: from C:/D/git-repo/chef-repo/chef/lib/chef/knife.rb:474:in `run_with_pretty_exceptions'
        22: from C:/D/git-repo/chef-repo/chef/lib/chef/local_mode.rb:42:in `with_server_connectivity'
        21: from C:/D/git-repo/chef-repo/chef/lib/chef/knife.rb:475:in `block in run_with_pretty_exceptions'
        20: from C:/D/git-repo/chef-repo/chef/lib/chef/knife/bootstrap.rb:572:in `run'
        19: from C:/D/git-repo/chef-repo/chef/lib/chef/knife/bootstrap.rb:1037:in `upload_bootstrap'
        18: from C:/D/git-repo/chef-repo/chef/lib/chef/knife/bootstrap/train_connector.rb:155:in `upload_file_content!'
        17: from C:/D/git-repo/chef-repo/chef/lib/chef/knife/bootstrap/train_connector.rb:140:in `upload_file!'
        16: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.7/lib/train/transports/ssh_connection.rb:115:in `upload'
        15: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.7/lib/train/transports/ssh_connection.rb:115:in `each'
        14: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/channel.rb:272:in `wait'
        13: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/session.rb:181:in `loop'
        12: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/session.rb:181:in `loop'
        11: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/session.rb:181:in `block in loop'
        10: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/session.rb:228:in `process'
         9: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/event_loop.rb:29:in `process'
         8: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/event_loop.rb:101:in `ev_preprocess'
         7: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/event_loop.rb:101:in `each'
         6: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/session.rb:249:in `ev_preprocess'
         5: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/session.rb:549:in `dispatch_incoming_packets'
         4: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/session.rb:682:in `channel_close'
         3: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/session.rb:573:in `channel_closed'
         2: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh/connection/channel.rb:610:in `do_close'
         1: from C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-scp-2.0.0/lib/net/scp.rb:365:in `block (3 levels) in start_command'
C:/opscode/chef/embedded/lib/ruby/gems/2.6.0/gems/net-scp-2.0.0/lib/net/scp.rb:398:in `await_response_state': scp: command error: Control characters detected. (Net::SCP::Error)
@kapilchouhan99

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2019

we are facing Net::SCP::Error because of windows node is not giving correct output.
when I am trying to bootstrap a windows node with ssh(Bitvise SSH Server), at that time it's not giving a correct stdout, stdout contains ANSI escape codes like this: \e[?7l\e[H\e[2J\e]2;Administrator: Command Prompt\a\e[?25l\e[1;1H\e[37m\e[40mC:\\Users\\kapil_chouhan\\AppData\\Local\\Temp\\7ca55b18-2445-4cc1-ac78-d6f92c5f2737\e[2;1H\e[?12l\e[?25h\e[?7h

@kapilchouhan99

This comment has been minimized.

Copy link
Contributor Author

commented Jun 26, 2019

Did some debugging and found a root cause of incorrect format, when train object contain pty: true option at that time we got stdout like \e[?7l\e[H\e[2J\e]2;Administrator: Command Prompt\a\e[?25l\e[1;1H\e[37m\e[40mC:\\Users\\kapil_chouhan\\AppData\\Local\\Temp\\7ca55b18-2445-4cc1-ac78-d6f92c5f2737\e[2;1H\e[?12l\e[?25h\e[?7h
so we need to change this condition https://github.com/chef/chef/blob/v15.1.26/lib/chef/knife/bootstrap.rb#L894

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.