Skip to content

Instantly share code, notes, and snippets.

@Yukaii
Created May 24, 2020 16:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yukaii/baa8b6fda3a25b043a109fcdbe460395 to your computer and use it in GitHub Desktop.
Save Yukaii/baa8b6fda3a25b043a109fcdbe460395 to your computer and use it in GitHub Desktop.
GNU Pass to Bitwarden migration

GNU Pass to Bitwarden migration

  1. Use pass2csv to export generic csv
  2. Add header folder,name,password,comments to first line of that csv file
  3. Use the script to convert file
  4. Import password with "Bitwarden (csv)" format

Remeber to delete your csv file safely once it's imported!

const fs = require('fs');
const path = require('path');
const csv = require('fast-csv');
fs.createReadStream(path.resolve(__dirname, 'pass.csv'))
.pipe(csv.parse({ headers: true }))
.pipe(csv.format({ headers: true }))
// .on('data', row => console.log(row))
.transform((row, next) => {
let login = ''
let url = ''
if (row.comments && row.comments.match(/login: (.+)/)) {
let match = row.comments.match(/login: (.+)/)
login = match[1]
}
if (!login) {
login = row.name
}
if (row.comments && row.comments.match(/url: (.+)/)) {
let match = row.comments.match(/url: (.+)/)
url = match[1]
}
return next(null, {
folder: row.folder,
favorite: '',
type: 'login',
name: row.name,
notes: row.comments,
fields: '',
login_uri: url,
login_username: login,
login_password: row.password,
login_totp: ''
})
})
.pipe(process.stdout)
.on('end', process.exit);
@Msouza91
Copy link

Msouza91 commented Oct 30, 2021

I know you did this to yourself, but how do you run this code? I'm looking into this exact migration and have managed to export the csv with the first tool you mention in the gist, but I don't understand the need for and how to run your code. I'm sorry if this is a bad question, I don't know much about JS

Edit:
I figured it out, just call node and pass the file as argument node covert.js > bit-pass.csv with the pass.csv file in the same directory, might be a trivial detail, but it may save some time for someone that didn't know like me! :D. Oh and I changed the login_totp to a header that I created since I was using the otp extension for pass.
Thanks a lot for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment