1

Recently, someone (who is using Windows10) ask me that his VSCode's remote (ssh) connect is unavailable. After a bunch of checking, I found his ~/.ssh/authorized_keys ends with "^M" (in Vim) and removing that symbol resolves his problem.

To modify/remove "^M" is easy. But this time I'd like to figure out what is "^M" and how it is generated? Knowing how it is generated would help people avoid generating "^M" and related issues.

ChrisZZ
  • 1,521
  • 2
  • 17
  • 24
  • Don't know why this question got downvoted...If you think it's a bad question, please comment out why you think it is bad and even please give advice about how to improve it....instead of just downvote it. – ChrisZZ May 21 '20 at 13:31
  • Hi, if you look at @m000 's answer to this question, https://superuser.com/questions/473614/vim-shows-m-symbols-and-they-arent-disappearing, you will see a good explanation. – Patrick Bacon May 21 '20 at 13:36
  • Does this answer your question? [How to convert the ^M linebreak to 'normal' linebreak in a file opened in vim?](https://stackoverflow.com/questions/811193/how-to-convert-the-m-linebreak-to-normal-linebreak-in-a-file-opened-in-vim) – phd May 21 '20 at 13:36
  • 3
    https://stackoverflow.com/search?q=%5Bvim%5D+%22%5EM%22 – phd May 21 '20 at 13:36
  • @PatrickBacon @phd My question concern what does `^M` mean and how it is generated, instead of how to modify/remove them. – ChrisZZ May 21 '20 at 14:18

1 Answers1

3

^M is Vim's representation of ASCII 13 (M being the 13th letter of the alphabet), carriage return. ssh assumes that the file will use Unix line endings, so it treats the CR of the CR/LF pair in the DOS file as a regular character, rather than ignoring it as a line terminator. Removing the ^M essentially converts the file from a DOS text file to the POSIX text file that ssh expects.

chepner
  • 497,756
  • 71
  • 530
  • 681